Search…
API Reference
Resources
Create a tax category
How to create a tax category via API
To create a new tax category, send a POST request to the /api/tax_categories endpoint, passing the resource arguments in the request body.

Request

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

Arguments

Body Parameter
Type
Required
type
string
Required
attributes.code
string
Required
attributes.sku_code
string
Optional
attributes.reference
string
Optional
attributes.reference_origin
string
Optional
attributes.metadata
object
Optional
relationships.sku
object
Required
relationships.tax_calculator
object
Required

Example

Request
Response
The following request creates a new tax category:
1
curl -g -X POST \
2
'https://yourdomain.commercelayer.io/api/tax_categories' \
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": "tax_categories",
9
"attributes": {
10
"code": "31000"
11
},
12
"relationships": {
13
"sku": {
14
"data": {
15
"type": "skus",
16
"id": "QWERtyUpBa"
17
}
18
},
19
"tax_calculator": {
20
"data": {
21
"type": "tax_calculators",
22
"id": "QWERtyUpBa"
23
}
24
}
25
}
26
}
27
}'
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": "tax_categories",
5
"links": {
6
"self": "https://yourdomain.commercelayer.io/api/tax_categories/xYZkjABcde"
7
},
8
"attributes": {
9
"code": "31000",
10
"sku_code": "TSHIRTMM000000FFFFFFXLXX",
11
"created_at": "2018-01-01T12:00:00.000Z",
12
"updated_at": "2018-01-01T12:00:00.000Z",
13
"reference": "ANY-EXTERNAL-REFEFERNCE",
14
"reference_origin": "ANY-EXTERNAL-REFEFERNCE-ORIGIN",
15
"metadata": {
16
"foo": "bar"
17
}
18
},
19
"relationships": {
20
"sku": {
21
"links": {
22
"self": "https://yourdomain.commercelayer.io/api/tax_categories/xYZkjABcde/relationships/sku",
23
"related": "https://yourdomain.commercelayer.io/api/tax_categories/xYZkjABcde/sku"
24
}
25
},
26
"tax_calculator": {
27
"links": {
28
"self": "https://yourdomain.commercelayer.io/api/tax_categories/xYZkjABcde/relationships/tax_calculator",
29
"related": "https://yourdomain.commercelayer.io/api/tax_categories/xYZkjABcde/tax_calculator"
30
}
31
},
32
"attachments": {
33
"links": {
34
"self": "https://yourdomain.commercelayer.io/api/tax_categories/xYZkjABcde/relationships/attachments",
35
"related": "https://yourdomain.commercelayer.io/api/tax_categories/xYZkjABcde/attachments"
36
}
37
}
38
},
39
"meta": {
40
"mode": "test"
41
}
42
}
43
}
Copied!
Last modified 2mo ago
Copy link