Skip to main content

Upload attachments

Understand how to upload attachments to records in Codat's supported accounting software

Codat offers the ability to upload attachment to records in the supported accounting software. You can write an attachment for the following accounting data types:

Data typeUploadAttachment
billCreditNotes
bills
directCosts
directIncomes
invoices
transfers

Attachment upload process

An attachment upload process at Codat consists of the following steps:

  1. Make a write request

    Once completed, you will receive a write request ID. Use it to track the status of the request.

  2. Consume the relevant write webhook

    Subscribe to the relevant {dataType}.write.{successful|unsuccessful} webhookWebhook An automated notification sent from Codat to your application when specific events occur, such as when data syncs complete or connections change status. to receive notifications of the success or failure of the write request.

Make a write request

To upload an attachment to a record, include the companyCompany In Codat, a company represents your customer's business entity. Companies can have multiple connections to different data sources. ID, relevant connectionConnection A link between a Codat company and a data source (like an accounting platform). Each connection represents authorized access to pull or push data from that platform. ID, the record ID for the data type, and the attachment file itself in your APIAPI A set of rules and protocols that allows different software applications to communicate with each other. Codat provides APIs for accessing financial data from accounting, banking, and commerce platforms. call.

In the example below, we are uploading an attachment for our bills data type.

const uploadAttachmentResponse = await sdk.bills.uploadAttachment({
companyId: companyId,
connectionId: connectionId,
billId: billId,
attachmentUpload: {
file: {
content: new TextEncoder().encode(fileContent),
fileName: fileName,
},
},
});

Consume the write webhookWebhook An automated notification sent from Codat to your application when specific events occur, such as when data syncs complete or connections change status.

Subscribe to our data type-specific webhooksWebhook An automated notification sent from Codat to your application when specific events occur, such as when data syncs complete or connections change status. to track the outcome of a completed write request:

  • {dataType}.write.successful
  • {dataType}.write.unsuccessful

To create a webhookWebhook An automated notification sent from Codat to your application when specific events occur, such as when data syncs complete or connections change status. consumer for these event types, navigate to Settings > WebhooksWebhook An automated notification sent from Codat to your application when specific events occur, such as when data syncs complete or connections change status. > Events > Configure consumer in the Codat Portal and click Add endpoint. See Build webhook consumers to subscribe to events for detailed instructions.

The webhookWebhook An automated notification sent from Codat to your application when specific events occur, such as when data syncs complete or connections change status.'s payload includes information about the companyCompany In Codat, a company represents your customer's business entity. Companies can have multiple connections to different data sources. ID and record ID the attachment upload was attempted for. If the write operation is successful, the payload also includes the attachment ID. We provided an example webhookWebhook An automated notification sent from Codat to your application when specific events occur, such as when data syncs complete or connections change status. payload for a successful write operation uploading an attachment to a bill.

Example webhook payload
{
"id": "bae71d36-ff47-420a-b4a6-f8c9ddf41140",
"eventType": "bills.write.successful",
"generatedDate": "2023-05-03T10:00:23.000Z",
"payload": {
"id": "a9367074-b5c3-42c4-9be4-be129f43577e",
"type": "Create",
"referenceCompany": {
"id": "70af3071-65d9-4ec3-b3cb-5283e8d55dac",
"name": "Toft stores"
},
"connectionId": "12571faf-0898-47e7-afdd-0fe9eb0a9bf5",
"requestedOnDate": "2023-05-03T10:00:00.000Z",
"completedOnDate": "2023-05-03T10:00:23.000Z",
"status": "Success",
"record": {
"id": "bil_1Nispe2eZvKYlo2Cd31jOCgZ"
},
"attachmentId": "att_2Ksoie6eDvErJo249lsieqpD9"
}
}

Was this page useful?
👏
👍
🤔
👎
😭