Create a Shipping Method
Creates a Shipping Method
POST
/
api
/
v2
/
platform
/
shipping_methods
Create a Shipping Method
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
shipping_method: {
name: 'DHL Express',
display_on: 'both',
shipping_category_ids: ['2'],
admin_name: 'DHL Area Code D',
code: 'DHL-A-D',
tracking_url: 'dhlexpress.com?tracking=',
tax_category_id: '1',
public_metadata: {},
private_metadata: {}
}
})
};
fetch('http://{defaultHost}/api/v2/platform/shipping_methods', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url http://{defaultHost}/api/v2/platform/shipping_methods \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"shipping_method": {
"name": "DHL Express",
"display_on": "both",
"shipping_category_ids": [
"2"
],
"admin_name": "DHL Area Code D",
"code": "DHL-A-D",
"tracking_url": "dhlexpress.com?tracking=",
"tax_category_id": "1",
"public_metadata": {},
"private_metadata": {}
}
}
'{
"data": {
"id": "81",
"type": "shipping_method",
"attributes": {
"name": "DHL Express Domestic",
"code": "DDD",
"admin_name": "DHL Express- Zone A",
"display_on": "both",
"tracking_url": null,
"created_at": "2022-11-08T19:35:24.485Z",
"updated_at": "2022-11-08T19:35:24.485Z",
"deleted_at": null,
"public_metadata": {},
"private_metadata": {}
},
"relationships": {
"shipping_categories": {
"data": [
{
"id": "148",
"type": "shipping_category"
}
]
},
"shipping_rates": {
"data": []
},
"tax_category": {
"data": {
"id": "142",
"type": "tax_category"
}
},
"calculator": {
"data": {
"id": "141",
"type": "calculator"
}
}
}
}
}{
"error": "Calculator can't be blank, Name can't be blank, Display on can't be blank, and You must select at least one shipping category",
"errors": {
"calculator": [
"can't be blank"
],
"name": [
"can't be blank"
],
"display_on": [
"can't be blank"
],
"base": [
"You must select at least one shipping category"
]
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Query Parameters
Select which associated resources you would like to fetch, see: https://jsonapi.org/format/#fetching-includes
Body
application/json
Show child attributes
Show child attributes
Response
Record created
Show child attributes
Show child attributes
Was this page helpful?
⌘I
Create a Shipping Method
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
shipping_method: {
name: 'DHL Express',
display_on: 'both',
shipping_category_ids: ['2'],
admin_name: 'DHL Area Code D',
code: 'DHL-A-D',
tracking_url: 'dhlexpress.com?tracking=',
tax_category_id: '1',
public_metadata: {},
private_metadata: {}
}
})
};
fetch('http://{defaultHost}/api/v2/platform/shipping_methods', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));curl --request POST \
--url http://{defaultHost}/api/v2/platform/shipping_methods \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"shipping_method": {
"name": "DHL Express",
"display_on": "both",
"shipping_category_ids": [
"2"
],
"admin_name": "DHL Area Code D",
"code": "DHL-A-D",
"tracking_url": "dhlexpress.com?tracking=",
"tax_category_id": "1",
"public_metadata": {},
"private_metadata": {}
}
}
'{
"data": {
"id": "81",
"type": "shipping_method",
"attributes": {
"name": "DHL Express Domestic",
"code": "DDD",
"admin_name": "DHL Express- Zone A",
"display_on": "both",
"tracking_url": null,
"created_at": "2022-11-08T19:35:24.485Z",
"updated_at": "2022-11-08T19:35:24.485Z",
"deleted_at": null,
"public_metadata": {},
"private_metadata": {}
},
"relationships": {
"shipping_categories": {
"data": [
{
"id": "148",
"type": "shipping_category"
}
]
},
"shipping_rates": {
"data": []
},
"tax_category": {
"data": {
"id": "142",
"type": "tax_category"
}
},
"calculator": {
"data": {
"id": "141",
"type": "calculator"
}
}
}
}
}{
"error": "Calculator can't be blank, Name can't be blank, Display on can't be blank, and You must select at least one shipping category",
"errors": {
"calculator": [
"can't be blank"
],
"name": [
"can't be blank"
],
"display_on": [
"can't be blank"
],
"base": [
"You must select at least one shipping category"
]
}
}
