Search…
API Reference
Resources
List all attachments
How to fetch a collection of attachments via API
To fetch a collection of attachments, send a GET request to the /api/attachments endpoint.

Request

GET https://yourdomain.commercelayer.io/api/attachments

Example

Request
Response
The following request fetches a collection of attachments:
1
curl -g -X GET \
2
'https://yourdomain.commercelayer.io/api/attachments/' \
3
-H 'Accept: application/vnd.api+json' \
4
-H 'Authorization: Bearer your-access-token'
Copied!
On success, the API responds with a 200 OK status code, returning a paginated collection of resource objects:
1
{
2
"data": [
3
{
4
"id": "xYZkjABcde",
5
"type": "attachments",
6
"links": {
7
"self": "https://yourdomain.commercelayer.io/api/attachments/xYZkjABcde"
8
},
9
"attributes": {
10
"name": "DDT transport document",
11
"description": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
12
"url": "https://s3.yourdomain.com/attachment.pdf",
13
"created_at": "2018-01-01T12:00:00.000Z",
14
"updated_at": "2018-01-01T12:00:00.000Z",
15
"reference": "ANY-EXTERNAL-REFEFERNCE",
16
"reference_origin": "ANY-EXTERNAL-REFEFERNCE-ORIGIN",
17
"metadata": {
18
"foo": "bar"
19
}
20
},
21
"relationships": {
22
"attachable": {
23
"links": {
24
"self": "https://yourdomain.commercelayer.io/api/attachments/xYZkjABcde/relationships/attachable",
25
"related": "https://yourdomain.commercelayer.io/api/attachments/xYZkjABcde/attachable"
26
}
27
}
28
},
29
"meta": {
30
"mode": "test"
31
}
32
},
33
{
34
"other": "... 9 attachments (first page)"
35
}
36
],
37
"meta": {
38
"record_count": 140,
39
"page_count": 14
40
},
41
"links": {
42
"first": "https://yourdomain.commercelayer.io/api/attachments?page[number]=1&page[size]=10",
43
"next": "https://yourdomain.commercelayer.io/api/attachments?page[number]=2&page[size]=10",
44
"last": "https://yourdomain.commercelayer.io/api/attachments?page[number]=14&page[size]=10"
45
}
46
}
Copied!

Sortable attributes

The list of attachments can be sorted by the following attributes:
  • id
  • created_at
  • updated_at
  • reference
  • reference_origin
Last modified 2mo ago