Sign inGet Started

Create pre-signed upload

This API generates a pre-signed URL for media uploads. It responds with information required to build a subsequent form data request to upload the media to an S3 bucket. Please refer to Examples below on how to use it.
POST
/workspaces/{workspaceId}/conversations/{conversationId}/presigned-upload
Creates a pre-signed URL to upload media that can be used when sending messages in a conversation. The maximum fize size is 100MiB.
Payload permintaan
contentType
string
wajib
The MIME type of the media being uploaded.
Payload respons
mediaUrl
string
wajib
The URL to use when sending messages with this media. Must be passed in the attachments object.
uploadUrl
string
wajib
The URL to upload the media using form data encoding. The media must be sent with the field name file in addition to fields in uploadFormData.
uploadMethod
string
wajib
The method to use when uploading the media, will always be POST.
uploadFormData
object
wajib
Form data fields that must be passed in addition to the field file when uploading the media to uploadUrl.
Contoh kode
curl -X POST 'https://api.bird.com/workspaces/{workspaceId}/conversations/{conversationId}/presigned-upload' \
  -H 'Authorization: AccessKey YOUR_ACCESS_KEY'

Examples

In the following example, we'll generate a pre-signed upload URL, then use it to upload media, and finally send a message with it:
  1. Generate URL
Contoh kode
curl -X POST "https://api.bird.com/workspaces/a1405560-c8d3-4b1a-877d-3f449ad95352/conversations/02ec2ac2-ebec-42d3-a5f4-e6f3a9edf418/presigned-upload" \
-H "Authorization: AccessKey abcd"
  1. Upload media to pre-signed URL
All of the fields in uploadFormData from the previous response need to be passed as form data string fields. Additionally, the field file must contain the media file you'd like to upload.
The response status is 204 (No Content).
Contoh kode
curl 'https://channels--message-media--151603429280--euw1.s3.eu-west-1.amazonaws.com' \
-F 'Content-Type="image/png"' \
-F 'acl="private"' \
-F 'bucket="channels--message-media--151603429280--euw1"' \
-F 'key="a1405560-c8d3-4b1a-877d-3f449ad95352/e867a2ac-2df5-40be-a5d4-e452d7156048"' \
-F 'policy="c29tZSByYW5kb20gYmFzZTY0IHNvbWUgcmFuZG9tIGJhc2U2NCBzb21lIHJhbmRvbSBiYXNlNjQ="' \
-F 'x-amz-algorithm="AWS4-HMAC-SHA256"' \
-F 'x-amz-credential="ASIAZIY3TY7LKB5VSROM/20241202/us-east-2/s3/aws4_request"' \
-F 'x-amz-date="20241202T151755Z"' \
-F 'x-amz-meta-allowed-paths="/workspaces/a1405560-c8d3-4b1a-877d-3f449ad95352/conversations/02ec2ac2-ebec-42d3-a5f4-e6f3a9edf418/media/e867a2ac-2df5-40be-a5d4-e452d7156048"' \
-F 'x-amz-meta-channel-id="cb4b1ebc-34e6-5a7a-a375-f6f2f131d88f"' \
-F 'x-amz-meta-conversation-id="02ec2ac2-ebec-42d3-a5f4-e6f3a9edf418"' \
-F 'x-amz-security-token="dmJ0h6xCpr/DysEQmSWORwF7HggMJq6GSSAXUCA0lDY="' \
-F 'x-amz-signature="22986b67e42558bc2f44b970d8a8c0357832540245a5c80df1229f4166c9d73c"' \
-F 'file=@"./bird.png"'
  1. Send message with media
Contoh kode
curl -X POST "https://api.bird.com/workspaces/a1405560-c8d3-4b1a-877d-3f449ad95352/conversations/02ec2ac2-ebec-42d3-a5f4-e6f3a9edf418/messages" \
-H "Content-Type: application/json" \
-H "Authorization: AccessKey abcd" \
-d '{
  "participantType": "accessKey",
  "participantId": "0c0defe3-c98d-46d9-a9bf-febc1e08aa0c",
  "addMissingParticipants": true,
  "recipients": [
    {
      "type": "to",
      "identifierKey": "emailaddress",
      "identifierValue": "some.customer@example.com"
    }
  ],
  "body": {
    "type": "html",
    "html": {
      "attachments": [
        {
          "inline": true,
          "filename": "my_file",
          "mediaUrl": "https://media.api.bird.com/workspaces/a1405560-c8d3-4b1a-877d-3f449ad95352/conversations/02ec2ac2-ebec-42d3-a5f4-e6f3a9edf418/media/e867a2ac-2df5-40be-a5d4-e452d7156048"
        }
      ],
      "html": "<!doctype html><body><img src=\"cid:my_file\"></img></body></html>"
    }
  }
}'