Attachment Field Value
An attachment field value consists of its value
property which holds a reference to an attachment. An attachment has the properties id
(unique ID), filename
(the filename), size
(filesize in bytes), download_url
(URL to download the file) and others.
A single_attachment
field value holds at most one attachment reference while a multi_attachment
field value can hold multiple attachment references.
Attachment fields behave quite similarly to image fields, also allowing non-image files.
More details on the file object and the two-step file upload process can be found here.
Record creation
A attachment field value can be created as part of a record creation. Files can be specified as temporary file IDs (strings), existing file IDs of the same field (integers) and existing file IDs of different Attachment or Image fields (integers). Here is an example request body for creating a record with a value for the "Letter of recommendation" field with ID 2, type single_attachment
and external ID letter_of_recommendation
and a value for the "HR documents" field with ID 3, type multi_attachment
and external ID hr_documents
:
- cURL
- JSON
curl -X POST https://api.tapeapp.com/v1/record/app/1 \
-u user_key_replace_with_your_api_key: \
-H "Content-Type: application/json" \
--data '{
"fields": {
"letter_of_recommendation": "temporary-file-1",
"hr_documents": ["temporary-file-2", "temporary-file-3"]
}
}'
{
"fields": {
"letter_of_recommendation": "temporary-file-1",
"hr_documents": ["temporary-file-2", "temporary-file-3"]
}
}
{
"record_id": 1,
"title": "200301_letter-of-recommendation.pdf",
"fields": [
{
"field_id": 2,
"external_id": "letter_of_recommendation",
"label": "Letter of recommendation",
"type": "attachment",
"field_type": "single_attachment",
"values": [
{
"value": {
"id": 100,
"filename": "200301_letter-of-recommendation.pdf",
"size": 12300
}
}
]
},
{
"field_id": 3,
"external_id": "hr_documents",
"label": "HR Documents",
"field_type": "multi_attachment",
"type": "attachment",
"values": [
{
"value": {
"id": 101,
"filename": "200301_hr_document-1.pdf",
"size": 15000
}
},
{
"value": {
"id": 102,
"filename": "200301_hr_document-2.pdf",
"size": 16000
}
}
]
}
]
}
Record retrieval
A attachment field value can be retrieved as part of a record retrieval:
curl https://api.tapeapp.com/v1/record/1 \
-u user_key_replace_with_your_api_key:
{
"record_id": 1,
"title": "200301_letter-of-recommendation.pdf",
"fields": [
{
"field_id": 2,
"external_id": "letter_of_recommendation",
"label": "Letter of recommendation",
"type": "attachment",
"field_type": "single_attachment",
"values": [
{
"value": {
"id": 100,
"filename": "200301_letter-of-recommendation.pdf",
"size": 12300
}
}
]
},
{
"field_id": 3,
"external_id": "hr_documents",
"label": "HR Documents",
"field_type": "multi_attachment",
"type": "attachment",
"values": [
{
"value": {
"id": 101,
"filename": "200301_hr_document-1.pdf",
"size": 15000
}
},
{
"value": {
"id": 102,
"filename": "200301_hr_document-2.pdf",
"size": 16000
}
}
]
}
]
}
Record update
One or more attachment field values can be updated as part of a record update. Existing IDs of the same field (integers), existing IDs of different Attachment or Image fields (integers) as well as temporary file IDs (strings) can be provided as input. Here is an example request body for updating multiple attachment field values of a record:
- cURL
- JSON
curl -X PUT https://api.tapeapp.com/v1/record/1 \
-u user_key_replace_with_your_api_key: \
-H "Content-Type: application/json" \
--data '{
"fields": {
"letter_of_recommendation": "temporary-file-2",
"hr_documents": ["temporary-file-6", 102]
}
}'
{
"fields": {
"letter_of_recommendation": "temporary-file-2",
"hr_documents": ["temporary-file-6", 102]
}
}
{
"record_id": 1,
"title": "200301_letter-of-recommendation.pdf",
"fields": [
{
"field_id": 2,
"external_id": "letter_of_recommendation",
"label": "Letter of recommendation",
"type": "attachment",
"field_type": "single_attachment",
"values": [
{
"value": {
"id": 100,
"filename": "200301_letter-of-recommendation.pdf",
"size": 12300
}
}
]
},
{
"field_id": 3,
"external_id": "hr_documents",
"label": "HR Documents",
"field_type": "multi_attachment",
"type": "attachment",
"values": [
{
"value": {
"id": 101,
"filename": "200301_hr_document-1.pdf",
"size": 15000
}
},
{
"value": {
"id": 102,
"filename": "200301_hr_document-2.pdf",
"size": 16000
}
}
]
}
]
}