When you create a message with the Kustomer API you would include the attachment ID of the attachment you created in the attachments array on the message object.
You need to send a Patch request to the message you want to add this attachment to. Attachments are added to messages, not Conversations.
The attachment you created would look something like this:
"data": {
"id": "5ec42bbad47d84001a0dd107",
"type": "attachment",
"attributes": {
"name": "testing.png",
"contentType": "image/png",
"contentLength": 1282,
"redacted": false,
"uploaded": false,
"createdAt": "2020-05-19T18:55:54.390Z",
"updatedAt": "2020-05-19T18:55:54.390Z",
"context": "attachment"
},
"relationships": {
"org": {
"data": {
"id": "5e664db1c9639a0019c67fd0",
"type": "org"
},
"links": {
"self": "/v1/orgs/5e664db1c9639a0019c67fd0"
}
}
},
"links": {
"self": "/v1/attachments/5ec42bbad47d84001a0dd107"
}
},
"meta": {
"provider": "s3",
"upload": {
"url": "https://s3.amazonaws.com/kustomer-prod1-attachments",
"fields": {
"key": "attachments/5e664db1c9639a0019c67fd0/5ec42bbad47d84001a0dd107-testing.png",
"acl": "private",
"Content-Type": "image/png",
"X-Amz-Meta-Attachment-Id": "5ec42bbad47d84001a0dd107",
"bucket": "kustomer-prod1-attachments",
"X-Amz-Algorithm": "AWS4-HMAC-SHA256",
"X-Amz-Credential": "AKIAIIKHW25JWTRL7R7Q/20200519/us-east-1/s3/aws4_request",
"X-Amz-Date": "20200519T185554Z",
"Policy": "eyJleHBpcmF0aW9uIjoiMjAyMC0wNS0xOVQxOToyNTo1NFoiLCJjb25kaXRpb25zIjpbWyJjb250ZW50LWxlbmd0aC1yYW5nZSIsMTI4MiwxMjgyXSx7ImtleSI6ImF0dGFjaG1lbnRzLzVlNjY0ZGIxYzk2MzlhMDAxOWM2N2ZkMC81ZWM0MmJiYWQ0N2Q4NDAwMWEwZGQxMDctdGVzdGluZy5wbmcifSx7ImFjbCI6InByaXZhdGUifSx7IkNvbnRlbnQtVHlwZSI6ImltYWdlL3BuZyJ9LHsiWC1BbXotTWV0YS1BdHRhY2htZW50LUlkIjoiNWVjNDJiYmFkNDdkODQwMDFhMGRkMTA3In0seyJidWNrZXQiOiJrdXN0b21lci1wcm9kMS1hdHRhY2htZW50cyJ9LHsiWC1BbXotQWxnb3JpdGhtIjoiQVdTNC1ITUFDLVNIQTI1NiJ9LHsiWC1BbXotQ3JlZGVudGlhbCI6IkFLSUFJSUtIVzI1SldUUkw3UjdRLzIwMjAwNTE5L3VzLWVhc3QtMS9zMy9hd3M0X3JlcXVlc3QifSx7IlgtQW16LURhdGUiOiIyMDIwMDUxOVQxODU1NTRaIn1dfQ==",
"X-Amz-Signature": "f00ce41d04f3c962f68ac6f4f096b8054cb81183ab9dbc0e5dd795d12e0239dc"
}
}
}
You would need send another POST request to the meta.upload.url you found in your response form the attachment you created. Per the API documents this will need to include all of the meta.upload.fileds information in this POST request. Once you did that the attachement would have been uploaded. To add this to a message you would need to send a PATCH request to the message API end point.
https://api.kustomerapp.com/v1/messages/:id
https://apidocs.kustomer.com/?version=latest#959920e4-17ff-458d-af90-5458297f2148
You would add your attachment id in the attachments object on the message object.
"attachments": {
"links": {
"self": "/v1/messages/5ec15c3fb2f51f0019ebee09/attachments"
},
"data": [
{
"type": "attachment",
"id": "5ec15c71d120a7001ad1c14b"
}
]
}
I wanted to make an update here: The payload of the Patch request to the message would look like this:
{
"attachments":[
{
"_id": "5ec15c71d120a7001ad1c14b",
"name": "Yass.png",
"contentType": "image/png",
"contentLength": 11288
}
]
}
This would be for adding an attachment to an existing message. If you want to add an attachment to a message that has not yet been sent you would have to create a draft message and send a POST request to add the attachment to that draft. /v1/drafts/{id}/attachments
There would be two things you need to do here
- pass a sourceId in the body that is the ID of the original attachment
- I think in the request URL include a query param that says
?method=post
If you have further questions please reach out to the support@kustomer.com email and we would be happy to assist you.