10.9. Uploading documents to existing draft with cURLΒΆ
This example shows how to upload documents to an existing draft. The following example is a cURL PATCH
request
using bearer token for request authorization.
curl --location --request PATCH 'https://cargox.digital/api/v3/companies/self/inboxes/by-id/86252a14-71b8-4309-8d99-b3f06400385f/envelopes/by-id/87395226-535d-4b6b-b7fa-c11bcf9719a6/' \
--header 'Authorization: Bearer qB3b6Jqb8iyTP7bLhJ7wnRqTpf2Yaa' \
--form 'documents=@/path/to/document.pdf' \
--form 'documents=@/path/to/another-document.pdf'
Request body is a FormData object. Besides the documents
property, other draft fields can be patched with the same
request (see API reference). On success, the above cURL request returns the following JSON response:
{
"id": "87395226-535d-4b6b-b7fa-c11bcf9719a6",
"owner_id": "86252a14-71b8-4309-8d99-b3f06400385f",
"recipient_id": null,
"message": null,
"type": "outgoing",
"created": "2020-07-27T14:26:00.456069Z",
"sent": null,
"archived": null,
"delivered": null,
"action_performed_by_id": null,
"sealed": false,
"can_be_sealed": false,
"is_draft": true,
"sender_inbox_id": null,
"sender": null,
"delivered_envelope_opened": false,
"delivery_status": null,
"can_be_archived": false,
"can_be_unarchived": false,
"read_by_user": false,
"attachments": [
{
"id": "4ff8bba6-ed8c-48e6-b004-c7a19481838d",
"envelope_id": "87395226-535d-4b6b-b7fa-c11bcf9719a6",
"document_token_id": "dd442f79-93fa-426b-a552-4c9e25f9db33",
"document_token": {
"id": "dd442f79-93fa-426b-a552-4c9e25f9db33",
"storage_type": "disk",
"watermark_generated": false,
"ipfs_document_group_id": null,
"ipfs_document_group": null,
"document_id": "e49b6639-bbbc-48d1-867b-047bcd5664ca",
"document": {
"id": "e49b6639-bbbc-48d1-867b-047bcd5664ca",
"current_owner_id": "86252a14-71b8-4309-8d99-b3f06400385f",
"uploaded_by_id": "55ba1326-e07f-4293-b3b3-84db9f6efb90",
"uploaded_by": {
"name": "John Smith",
"first_name": "John",
"last_name": "Smith",
"email": "[email protected]",
"telephone": null,
"company_id": "aa69e1b4-a6ef-4a64-aa17-6c3f7adf8662",
"company": {
"name": "CargoX.io",
"branch": null,
"address": "Sample street 123",
"address2": "",
"postal_code": "1234",
"city": "Ljubljana",
"country": "SI",
"country_name": "Slovenia",
"website": "https://cargox.io",
"vat_number": null,
"logo": null,
"logo_name": "",
"id": "aa69e1b4-a6ef-4a64-aa17-6c3f7adf8662"
},
"logo": null,
"logo_name": "",
"id": "0102f020-6307-4a60-b7bb-c8a7dbea4d9d"
},
"type": null,
"document_id": null,
"create_on_blockchain": false,
"create_on_blockchain_override": false,
"accomplisher_id": null,
"accomplisher": null,
"accomplished": null,
"accomplished_by_id": null,
"destroyed": null,
"destroyed_by_id": null,
"notify_parties": null,
"meta_data": null,
"display_name": "document.pdf",
"file_name": "document.pdf",
"file_size": 2830,
"file_content_type": "application/pdf",
"icon": "pdf",
"file_type": "PDF",
"created": "2020-07-27T14:26:01.700658Z",
"thumbnail": null,
"thumbnail_mime_type": null
},
"attachment_count": 1,
"is_on_blockchain": false,
"can_be_destroyed": false,
"can_be_accomplished": false,
"destroy_pending": false,
"accomplish_pending": false,
"created": "2020-07-27T14:26:01.744566Z"
},
"used_in_envelope_id": null,
"can_be_forwarded": false
},
{
"id": "e43480cb-400c-430a-9420-38ddef4ae011",
"envelope_id": "87395226-535d-4b6b-b7fa-c11bcf9719a6",
"document_token_id": "3d600116-40c3-4def-835e-ea9839a2c961",
"document_token": {
"id": "3d600116-40c3-4def-835e-ea9839a2c961",
"storage_type": "disk",
"watermark_generated": false,
"ipfs_document_group_id": null,
"ipfs_document_group": null,
"document_id": "cf645aa3-56ac-4822-ae64-78666aeab312",
"document": {
"id": "cf645aa3-56ac-4822-ae64-78666aeab312",
"current_owner_id": "86252a14-71b8-4309-8d99-b3f06400385f",
"uploaded_by_id": "55ba1326-e07f-4293-b3b3-84db9f6efb90",
"uploaded_by": {
"name": "John Smith",
"first_name": "John",
"last_name": "Smith",
"email": "[email protected]",
"telephone": null,
"company_id": "aa69e1b4-a6ef-4a64-aa17-6c3f7adf8662",
"company": {
"name": "CargoX.io",
"branch": null,
"address": "Sample street 123",
"address2": "",
"postal_code": "1234",
"city": "Ljubljana",
"country": "SI",
"country_name": "Slovenia",
"website": "https://cargox.io",
"vat_number": null,
"logo": null,
"logo_name": "",
"id": "aa69e1b4-a6ef-4a64-aa17-6c3f7adf8662"
},
"logo": null,
"logo_name": "",
"id": "0102f020-6307-4a60-b7bb-c8a7dbea4d9d"
},
"type": null,
"document_id": null,
"create_on_blockchain": false,
"create_on_blockchain_override": false,
"accomplisher_id": null,
"accomplisher": null,
"accomplished": null,
"accomplished_by_id": null,
"destroyed": null,
"destroyed_by_id": null,
"notify_parties": null,
"meta_data": null,
"display_name": "another-document.pdf",
"file_name": "another-document.pdf",
"file_size": 147786,
"file_content_type": "application/pdf",
"icon": "pdf",
"file_type": "PDF",
"created": "2020-07-27T14:29:33.199650Z",
"thumbnail": null,
"thumbnail_mime_type": null
},
"attachment_count": 1,
"is_on_blockchain": false,
"can_be_destroyed": false,
"can_be_accomplished": false,
"destroy_pending": false,
"accomplish_pending": false,
"created": "2020-07-27T14:29:33.248270Z"
},
"used_in_envelope_id": null,
"can_be_forwarded": false
}
],
"delivered_envelope_id": null,
"failed_delivery_envelope_id": null,
"failed_outgoing_id": null,
"document_token_transactions": [],
"pay_to_collect": false,
"pay_to_collect_response": 0
}
Response is a serialized Envelope
object in JSON format representing the patched draft. Uploaded documents can be
found in the attachments
list.
If bearer token is invalid or expired, the following 403 Forbidden
response is returned:
{
"detail": "Authentication credentials were not provided."
}