API reference
Create an import
How to create an import via API
To create a new import, send a POST request to the /api/imports endpoint, passing the resource arguments in the request body.

Request

POST https://yourdomain.commercelayer.io/api/imports

Arguments

Body Parameter
Type
Required
type
string
Required
attributes.resource_type
string
Required
attributes.parent_resource_id
string
Optional
attributes.inputs
array
Required
attributes.cleanup_records
boolean
Optional
attributes.reference
string
Optional
attributes.reference_origin
string
Optional
attributes.metadata
object
Optional

Example

Request
Response
The following request creates a new import:
1
curl -g -X POST \
2
'https://yourdomain.commercelayer.io/api/imports' \
3
-H 'Accept: application/vnd.api+json' \
4
-H 'Authorization: Bearer your-access-token' \
5
-H 'Content-Type: application/vnd.api+json' \
6
-d '{
7
"data": {
8
"type": "imports",
9
"attributes": {
10
"resource_type": "skus",
11
"inputs": [
12
{
13
"code": "ABC",
14
"name": "Foo"
15
},
16
{
17
"code": "DEF",
18
"name": "Bar"
19
}
20
]
21
}
22
}
23
}'
Copied!
On success, the API responds with a 201 Created status code, returning the created resource object:
1
{
2
"data": {
3
"id": "xYZkjABcde",
4
"type": "imports",
5
"links": {
6
"self": "https://yourdomain.commercelayer.io/api/imports/xYZkjABcde"
7
},
8
"attributes": {
9
"resource_type": "skus",
10
"parent_resource_id": "1234",
11
"status": "in_progress",
12
"started_at": "2018-01-01T12:00:00.000Z",
13
"completed_at": "2018-01-01T12:00:00.000Z",
14
"interrupted_at": "2018-01-01T12:00:00.000Z",
15
"inputs": [
16
{
17
"code": "ABC",
18
"name": "Foo"
19
},
20
{
21
"code": "DEF",
22
"name": "Bar"
23
}
24
],
25
"inputs_size": 300,
26
"errors_count": 30,
27
"warnings_count": 1,
28
"destroyed_count": 99,
29
"processed_count": 270,
30
"errors_log": {
31
"ABC": {
32
"name": [
33
"has already been taken"
34
]
35
}
36
},
37
"warnings_log": {
38
"ABC": [
39
"could not be deleted"
40
]
41
},
42
"cleanup_records": true,
43
"created_at": "2018-01-01T12:00:00.000Z",
44
"updated_at": "2018-01-01T12:00:00.000Z",
45
"reference": "ANY-EXTERNAL-REFEFERNCE",
46
"reference_origin": "ANY-EXTERNAL-REFEFERNCE-ORIGIN",
47
"metadata": {
48
"foo": "bar"
49
}
50
},
51
"relationships": {
52
"events": {
53
"links": {
54
"self": "https://yourdomain.commercelayer.io/api/imports/xYZkjABcde/relationships/events",
55
"related": "https://yourdomain.commercelayer.io/api/imports/xYZkjABcde/events"
56
}
57
}
58
},
59
"meta": {
60
"mode": "test"
61
}
62
}
63
}
Copied!
Copy link