Skip to main content

Create Shipping Method

Creates a new shipping method.

HTTP Request

POST/api/shipping/methods

Authorization

Authorization

  • Required: Yes
  • Permission: Staff or Admin
  • Authentication: Token-based (Authorization: Token <your_api_key>)

Request Body

FieldTypeRequiredDescription
activeBooleanNoWhether the shipping method is active
orderIntegerNoThe order in which the shipping method appears
nameStringYesName of the shipping method
imageIntegerNoID of the image associated with the shipping method
descriptionStringNoDescription of the shipping method
formulaStringYesFormula for calculating shipping costs

Example Requests

1import requests
2
3response = requests.post('http://www.example.com/api/shipping/methods', json={
4  'active': True,
5  'order': 1,
6  'name': 'Standard Shipping',
7  'image': 123,
8  'description': 'Delivery within 5-7 business days.',
9  'formula': 'base_cost + (weight * rate_per_kg)'
10}, headers={
11  'Authorization': 'Token <your_api_key>'
12})
13print(response.json())

Status Codes

CodeDescription
201Shipping method created successfully
400Bad request — invalid input
500Internal server error

Response Fields

FieldTypeDescription
idintegerUnique ID of the shipping method
activebooleanWhether the shipping method is active
orderintegerThe order in which the shipping method appears
namestringName of the shipping method
image_dataobjectImage data associated with the shipping method (id, type, name, size, human_readable_size, f, width, height, mode)
descriptionstringDescription of the shipping method
formulastringFormula for calculating shipping costs
created_atstring (ISO 8601)Timestamp when the shipping method was created
updated_atstring (ISO 8601)Timestamp when the shipping method was last updated

Image Data Object Fields:

FieldTypeDescription
idIntegerUnique ID of the image
typeStringFile type (read-only, auto-detected)
nameStringOriginal filename
sizeIntegerFile size in bytes (read-only)
human_readable_sizeStringHuman-readable file size (e.g., "2.5 MB")
fStringFile URL/path
widthIntegerImage width in pixels (images only, read-only)
heightIntegerImage height in pixels (images only, read-only)
modeStringImage color mode (images only, read-only)

Notes

  • The formula field is used to calculate shipping costs based on various parameters like weight, distance, etc.
  • Shipping methods can be ordered using the order field to control display priority