Sign offline

AI Tools

The Yoti Sign API has a ‘signed-documents’ function. This allows you to upload a file which has been physically signed by the user. When processing is successful the file will be added to the sign receipt and the recipient will be marked as having signed. If there are errors during this process, integrators will be notified through the sign_ offline _ upload_errors notification.

Sandbox POST https://demo.api.yotisign.com/v2/envelopes/:envelopeId/recipients/:recipientId/signed-documents
Production POST https://api.yotisign.com/v2/envelopes/:envelopeId/recipients/:recipientId/signed-documents

Headers explained

The following elements are needed:

Header

Content

Authorization

API Key to call the Yoti Sign API. This should be sent as a bearer token.

Content-Type

multipart/form-data


Example Code

const rp = require("request-promise"); const fs = require("fs"); const options = {}; //options object const signOffline = () => { const request = { method: "POST", uri: `<BASE_URL>/v2/envelopes/<envelopeId>/recipients/<recipientId>/signed-documents`, formData: { file: fs.createReadStream("path/to.pdf") }, headers: { authorization: "Bearer <API_KEY>", }, }; return rp(request) .then((body) => body) .catch((err) => err); }; //send request let result = await signOffline();
package com.yoti.sign; import java.io.File; import java.io.IOException; import java.net.URI; import javax.json.Json; import javax.json.JsonObject; import javax.json.JsonReader; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.entity.ContentType; import org.apache.http.entity.mime.MultipartEntityBuilder; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; public class Example { private static final String YOTI_SIGN_AUTH_TOKEN = "<YOUR_AUTH_TOKEN>"; private static final String YOTI_SIGN_BASE_URL = "https://api.yotisign.com/v2"; public static void main(String[] args) { // Create the client and HttpRequest CloseableHttpClient client = HttpClients.createDefault(); HttpPost httpPost = new HttpPost(); URI uri = URI.create(YOTI_SIGN_BASE_URL + "/envelopes/<envelopeId>/recipients/<recipientId>/signed-documents"); httpPost.setURI(uri); // Set the 'Authorization' header httpPost.setHeader("Authorization", "Bearer " + YOTI_SIGN_AUTH_TOKEN); // Create a Multipart request entity, and add the file to send // along with the options MultipartEntityBuilder formDataBuilder = MultipartEntityBuilder.create(); File file = new File("/path/to/your/file.pdf"); formDataBuilder.addBinaryBody("file", file); // Add the Multipart request entity to the Http request httpPost.setEntity(formDataBuilder.build()); try { // Perform the POST request and read the created envelope ID HttpResponse response = client.execute(httpPost); JsonReader reader = Json.createReader(response.getEntity().getContent()); JsonObject responseObject = reader.readObject(); } catch (IOException e) { e.printStackTrace(); } } }
<?php use GuzzleHttp\Client; use GuzzleHttp\Psr7\MultipartStream; use GuzzleHttp\Psr7\Request; use function GuzzleHttp\Psr7\stream_for; $request = new Request( 'POST', API_BASE_URL . '/envelopes/<envelopeId>/recipients/<recipientId>/signed-documents', [ 'Authorization' => 'Bearer ' . YOUR_API_KEY, ], new MultipartStream([ [ 'name' => 'file', 'contents' => stream_for(fopen('./example-document.pdf', 'r')), ] ]) ); $client = new Client(); $response = $client->send($request); $json = json_decode($response->getBody());
using (var pdfFileContent = new StreamContent( new FileStream( "test.pdf", FileMode.Open, FileAccess.Read))) { using (var optionsJsonContent = new StringContent( optionsJson, Encoding.UTF8)) { MultipartFormDataContent multiPartContent = new MultipartFormDataContent { { pdfFileContent, "file", "test.pdf" } }; using (HttpRequestMessage request = new HttpRequestMessage { Method = HttpMethod.Post, RequestUri = new Uri("https://api.yotisign.com/v2/envelopes/<envelopeId>/recipients/<recipientId>/signed-documents"), Content = multiPartContent }) { request.Headers.Add("Authorization", "Bearer " + yotiAuthenticationToken); using (HttpClient httpClient = new HttpClient()) { HttpResponseMessage response = httpClient.SendAsync(request).Result; } } } }
payload := &bytes.Buffer{} writer := multipart.NewWriter(payload) _ = writer.WriteField("options", options) file, err := os.Open("path/to.pdf") defer file.Close() formFile, err := writer.CreateFormFile("file",filepath.Base("path/to.pdf")) _, err = io.Copy(formFile, file) err = writer.Close() req, err := http.NewRequest("POST", "<BASE_URL>/v2/envelopes/<envelopeId>/recipients/<recipientId>/signed-documents", payload) req.Header.Add("Authorization", "Bearer <API_KEY>") req.Header.Add("Content-Type", "multipart/form-data") req.Header.Set("Content-Type", writer.FormDataContentType()) client := &http.Client{} response, err := client.Do(req) if err != nil { fmt.Println(err) } else { result, _ := ioutil.ReadAll(response.Body) }

Response Body

{ "status": "QUEUED" }

Error Codes

Error code

Description

400

Bad Request, example: id provided not a UUID

401

Unauthorised request, example: requesting the status on an envelope you are not authorised to view

413

The combined file sizes have exceeded the 75MB limit

422

The request body did not pass validation