Skip to main content

Attachments

About

This tutorial demonstrates how you can make use of the Attachments API. Attachments can be PDF's or images you would like to share with your customers as a download from the Landing Page.

The API is very flexible and allows you various ways to use it. Overall, you have the following options:

  • Upload a attachment and create a claim in a second step (Flow 1)
  • Create a claim and upload an attachment in a second step (Flow 2)
  • Upload an attachment and create multiple claims (all using the same attachment) in a second step (Flow 3)

As always, it depends which flow fits the best for your use case. If your handover time and start of reminder process is very close (immediate) we recommend to always create the attachments first. Otherwise, communication steps might fail due to missing attachments data.

This guide will walk you through the API steps to tackle flow 1.

Upload a new file

The upload endpoint allows you to upload a file with related custom metadata. The API returns you a ticketId which you can use in a second step for a claim creation in order to link (attach) the attachment to the claim.

curl --request POST 'https://api-demo.collect.ai/merchants/24/uploads' \
--location \
--header 'Authorization: Bearer mytoken' \
--form 'friendlyName=Invoice Aug 2020' \
--form 'fileName=@/temp/invoice.pdf'

Response:

{
"error": null,
"result": {
"ticketId": "T24-bt3rocpvbanp9m4ven2g.k0ybJgOfOZpT/qVxBXjdlr+Lm/g="
}
}

Create claim with attachment

In the second step you can create a claim with a list of attachments. Each attachment entry requires a source and sourceType property. Use the ticketId for the source and TICKET for the type.

curl --request POST 'https://api-demo.collect.ai/merchants/24/claims' \
--location \
--header 'Authorization: Bearer mytoken' \
--header 'Content-Type: application/json' \
--data-raw '[{
"debtorName": "Han",
"debtorLastName": "Solo",
"email": "han.solo@email.com",
"mobileNumber": "+49162123456",
"referenceNumber": "ref-1234567",
"currency": "EUR",
"items": [{
"reference": "invoice-3866",
"type": "PRIMARY",
"value": "1099",
"itemDate": "2020-01-09",
"dueDate": "2020-01-31"
}],
"attachments": [
{ "sourceType": "TICKET", "source": "T24-bt3rocpvbanp9m4ven2g.k0ybJgOfOZpT/qVxBXjdlr+Lm/g=" }
]
}]'

Response:

{
"error": null,
"result": [
{
"result": null,
"error": null,
"id": 4431543,
"referenceNumber": "ref-1234567"
}
]
}

If you want to learn more, checkout the Attachments API documentation. There are more endpoints allowing you to update and download attachments as well as providing you access to all available attachments of a given claim.