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
| Field | Type | Required | Description |
|---|---|---|---|
| active | Boolean | No | Whether the shipping method is active |
| order | Integer | No | The order in which the shipping method appears |
| name | String | Yes | Name of the shipping method |
| image | Integer | No | ID of the image associated with the shipping method |
| description | String | No | Description of the shipping method |
| formula | String | Yes | Formula for calculating shipping costs |
Example Requests
- 🐍 Python
- 🌐 Curl
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())1curl -X POST "http://www.example.com/api/shipping/methods" \
2-H "Authorization: Token <your_api_key>" \
3-H "Content-Type: application/json" \
4-d '{
5 "active": true,
6 "order": 1,
7 "name": "Standard Shipping",
8 "image": 123,
9 "description": "Delivery within 5-7 business days.",
10 "formula": "base_cost + (weight * rate_per_kg)"
11}'Status Codes
| Code | Description |
|---|---|
| 201 | Shipping method created successfully |
| 400 | Bad request — invalid input |
| 500 | Internal server error |
Response Fields
| Field | Type | Description |
|---|---|---|
| id | integer | Unique ID of the shipping method |
| active | boolean | Whether the shipping method is active |
| order | integer | The order in which the shipping method appears |
| name | string | Name of the shipping method |
| image_data | object | Image data associated with the shipping method (id, type, name, size, human_readable_size, f, width, height, mode) |
| description | string | Description of the shipping method |
| formula | string | Formula for calculating shipping costs |
| created_at | string (ISO 8601) | Timestamp when the shipping method was created |
| updated_at | string (ISO 8601) | Timestamp when the shipping method was last updated |
Image Data Object Fields:
| Field | Type | Description |
|---|---|---|
| id | Integer | Unique ID of the image |
| type | String | File type (read-only, auto-detected) |
| name | String | Original filename |
| size | Integer | File size in bytes (read-only) |
| human_readable_size | String | Human-readable file size (e.g., "2.5 MB") |
| f | String | File URL/path |
| width | Integer | Image width in pixels (images only, read-only) |
| height | Integer | Image height in pixels (images only, read-only) |
| mode | String | Image 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