How to upload attachments and attach to a Card / Record

This guide demonstrates how to upload attachments using the Pipefy GraphQL API and attach that information to cards and table records.

All the process to get a new file attached to a card/record consists of three steps, you will need to get a pre-signed URL from Pipefy, upload the file to this URL generated by the API and after use this URL to attach the file to a card field or directly to a card/record.

1. Generate pre-signed URL using the GraphQL API

You will need to use the createPresignedUrl to get the URL, this mutation returns the URL where will be possible to upload. We have two required parameters in this mutation, organizationId and the fileName.

Sample Mutation

mutation {
  createPresignedUrl(input: { organizationId: 123, fileName: "MyDocument.pdf" }){
    clientMutationId
    url
  }
}

Response

You will get a URL like that in theurl return field:

https://pipefy-production.s3-sa-east-1.amazonaws.com/orgs/8bd9ce63-a26b-412f-9d27-3a5776e3e16e/uploads/45da74d3-0e92-4e1c-a04e-2acc97169a3/SampleFile.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=BKIA6QQUS4NUNAO6IA%2F20180705%2Fsa-east-1%2Fs3%2Faws4_request&X-Amz-Date=20180705T215845Z&X-Amz-Expires=300&X-Amz-SignedHeaders=host&x-amz-acl=public-read&X-Amz-Signature=fa76e8bf28f88d8ceec1df8219912e103ad15f5ab4668f0fc9cea69109991aa

You will use this URL to make PUT request with the file data in the next step.

2. Upload data

After you got the URL to upload, you will need to do a PUT request to this URL and sending along the file.

Sample cURL commands

curl --request PUT
--url 'https://pipefy-production.s3-sa-east-1.amazonaws.com/orgs/ce63-a26b-412f-9d27-3a5776e16e/uploads/45da74d3-0e92-4e1c-a04e-2acc97169a3/SampleFile.pdf?...Signature=fa76e8bf28f88d8ceec1df8219912e103ad15f5ab4668f0fc9cea69109991aa'
--header 'Content-Type: application/pdf'
--data 'BINARY_DATA'

curl -v --upload-file SampleFile.pdf 'https://pipefy-production.s3-sa-east-1.amazonaws.com/orgs/ce63-a26b-412f-9d27-3a5776e16e/uploads/45da74d3-0e92-4e1c-a04e-2acc97169a3/SampleFile.pdf?...Signature=fa76e8bf28f88d8ceec1df8219912e103ad15f5ab4668f0fc9cea69109991aa'

3. Assign file to Card/Record

After you got a 200 OK from the AWS S3 server, you can get the final path that you use to send to Pipefy. You need to send the path from the URL to Pipefy, excluding domain and parameters.

Example:

Upload URL

Path to send to Pipefy

https://pipefy-production.s3-sa-east-1.amazonaws.com/orgs/8bd9c63-a26b-412f-9d27-3a5776e3e16e/uploads/45da74d5-0e92-4e1c-a04e-26acc97169a3/File.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=BKIA6QQUS4NUNAO6IA%2F20180705%2Fsa-east-1%2Fs3%2Faws4_request&X-Amz-Date=20180705T215845Z&X-Amz-Expires=300&X-Amz-SignedHeaders=host&x-amz-acl=public-read&X-Amz-Signature=fa76e8bf28f88d8ceec1df8219912e103ad15f5ab4668f0fc9cea69109991aa

orgs/8bd9c63-a26b-412f-9d27-3a5776e3e16e/uploads/45da74d5-0e92-4e1c-a04e-26acc97169a3/File.pdf

You can use this Path inside the createCard, updateCardField, setTableRecordFieldValue and createTableRecord mutations, to update attachment fields or card/record attachments.\

Sample

mutation {
  updateCardField(input: {card_id: 123, field_id: "attachment_field", new_value: ["orgs/8bd9ce63-a26b-412f-9d27-3a5776e3e16e/uploads/45da74d5-0e92-4e1c-a04e-26acc97169a3/SampleFile.pdf"]}) {
    clientMutationId
    success
  }
}

Did this page help you?