API v1 — Live
Orders API Documentation
Complete REST API reference for managing orders — fetch, create, update, and track order statuses programmatically.
Authentication
All API requests require a Bearer token in the Authorization header.
Authorization: Bearer YOUR_API_TOKEN
Contact your admin to generate an API token from Settings > API Tokens.
Base URL
Production
https://wegocod.com/api/v1
List Orders
Fetch your orders with optional filters and pagination.
GET
/api/v1/orders
Query Parameters
| Parameter | Type | Description |
|---|---|---|
| status | string optional | Filter by shipping status |
| from | date optional | Start date (YYYY-MM-DD) |
| to | date optional | End date (YYYY-MM-DD) |
| city | string optional | Filter by city |
| country | string optional | Country code (MA) |
| sort_by | string optional | Sort: created_at, amount, shipping_status |
| sort_dir | string optional | Direction: asc or desc |
| per_page | integer optional | Results per page (default: 25, max: 100) |
Example Request
curl -X GET "https://wegocod.com/api/v1/orders?status=delivered&per_page=10" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Accept: application/json"
Example Response
{
"status": "success",
"data": [
{
"id": "837",
"reference": "ORD-000837",
"external_reference": "ORD-000837",
"created_at": "2026-05-19T14:30:00+01:00",
"updated_at": "2026-05-20T09:15:00+01:00",
"customer": {
"name": "Karim Mansouri",
"phone": "+212661234567",
"country": "MA"
},
"delivery_address": {
"address_line": "123 Bd Mohammed V",
"city": "Casablanca",
"area": null,
"country": "MA",
"notes": "Ring doorbell twice"
},
"payment": {
"method": "cod",
"amount": 399,
"currency": "MAD",
"payment_status": "collected"
},
"items": [
{
"product_name": "Argivit Classic Tablets",
"sku": "MA-ArgivitClassic",
"quantity": 1,
"unit_price": 399,
"total_price": 399
}
],
"status": {
"overall": "delivered",
"call_center": { "status": "confirmed" },
"fulfillment": {
"status": "delivered",
"carrier": "Forcelog",
"tracking_number": "F-CSA6SFJ6EMY",
"carrier_status": "DELIVERED",
"updated_at": "2026-05-20T09:15:00+01:00"
}
}
}
],
"meta": {
"current_page": 1,
"per_page": 10,
"total": 53,
"last_page": 6
}
}
Get Single Order
Fetch a single order with full details including status history.
GET
/api/v1/orders/{order_reference}
Example Request
curl -X GET "https://wegocod.com/api/v1/orders/ORD-000837" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Accept: application/json"
Example Response
{
"status": "success",
"data": {
"order": {
"id": "837",
"reference": "ORD-000837",
"external_reference": "ORD-000837",
"created_at": "2026-05-19T14:30:00+01:00",
"updated_at": "2026-05-20T09:15:00+01:00",
"customer": {
"name": "Karim Mansouri",
"phone": "+212661234567",
"country": "MA"
},
"delivery_address": {
"address_line": "123 Bd Mohammed V",
"city": "Casablanca",
"area": null,
"country": "MA",
"notes": "Ring doorbell twice"
},
"payment": {
"method": "cod",
"amount": 399,
"currency": "MAD",
"payment_status": "collected"
},
"items": [
{
"product_name": "Argivit Classic Tablets",
"sku": "MA-ArgivitClassic",
"quantity": 1,
"unit_price": 399,
"total_price": 399
}
],
"status": {
"overall": "delivered",
"call_center": { "status": "confirmed" },
"fulfillment": {
"status": "delivered",
"carrier": "Forcelog",
"tracking_number": "F-CSA6SFJ6EMY",
"carrier_status": "DELIVERED",
"updated_at": "2026-05-20T09:15:00+01:00"
}
},
"status_history": [
{
"type": "shipping",
"status": "delivered",
"message": "Forcelog: DELIVERED",
"created_at": "2026-05-20T09:15:00+01:00"
},
{
"type": "shipping",
"status": "out_for_delivery",
"message": null,
"created_at": "2026-05-19T16:18:00+01:00"
},
{
"type": "call_center",
"status": "confirmed",
"message": "Order confirmed by call center",
"created_at": "2026-05-19T14:30:00+01:00"
}
]
}
}
}
Create Order
Create a new order with customer details and product items.
POST
/api/v1/orders
Request Body
| Field | Type | Description |
|---|---|---|
| recipient_name | string required | Customer full name |
| phone | string required | Phone number (+212...) |
| address | string required | Delivery address |
| city | string required | Delivery city (must match Forcelog cities) |
| country | string required | MA |
| delivery_notes | string optional | Notes for delivery driver |
| items | array required | Product items (min 1) |
| items[].product_id | integer required | Product ID |
| items[].quantity | integer required | Quantity (min 1) |
| items[].price | number optional | Custom price (defaults to product price) |
Example Request
curl -X POST "https://wegocod.com/api/v1/orders" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"recipient_name": "Karim Mansouri",
"phone": "+212661234567",
"address": "123 Bd Mohammed V",
"city": "Casablanca",
"country": "MA",
"items": [
{ "product_id": 14, "quantity": 1, "price": 399 },
{ "product_id": 15, "quantity": 1, "price": 499 }
]
}'
Response — 201 Created
{
"status": "success",
"message": "Order created successfully",
"data": {
"id": "850",
"reference": "ORD-000850",
"external_reference": "ORD-000850",
"created_at": "2026-05-22T10:00:00+01:00",
"updated_at": "2026-05-22T10:00:00+01:00",
"customer": {
"name": "Karim Mansouri",
"phone": "+212661234567",
"country": "MA"
},
"delivery_address": {
"address_line": "123 Bd Mohammed V",
"city": "Casablanca",
"area": null,
"country": "MA",
"notes": null
},
"payment": {
"method": "cod",
"amount": 898,
"currency": "MAD",
"payment_status": "pending_collection"
},
"items": [
{ "product_name": "Argivit Classic Tablets", "sku": "MA-ArgivitClassic", "quantity": 1, "unit_price": 399, "total_price": 399 },
{ "product_name": "Argivit Focus Tablets", "sku": "MA-ArgivitFocus", "quantity": 1, "unit_price": 499, "total_price": 499 }
],
"status": {
"overall": "confirmed_pending_fulfillment",
"call_center": { "status": "confirmed" },
"fulfillment": {
"status": "pending",
"carrier": null,
"tracking_number": null,
"carrier_status": null,
"updated_at": "2026-05-22T10:00:00+01:00"
}
}
}
}
Update Order
Update order details. Orders past
out_for_delivery cannot be edited.
PUT
/api/v1/orders/{order_reference}
Request Body (all fields optional)
| Field | Type | Description |
|---|---|---|
| recipient_name | string | Update customer name |
| phone | string | Update phone number |
| address | string | Update delivery address |
| city | string | Update city |
| delivery_notes | string | Update delivery notes |
| shipping_status | string | Change status (must follow valid flow) |
| reason | string | Reason for status change. Defaults to through api if not provided |
Example — Update Address
curl -X PUT "https://wegocod.com/api/v1/orders/ORD-000850" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"address": "456 Rue Hassan II, Etage 3",
"delivery_notes": "Appeler avant livraison"
}'
Example — Change Status with Reason
curl -X PUT "https://wegocod.com/api/v1/orders/ORD-000850" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"shipping_status": "delivered",
"reason": "Customer confirmed delivery via WhatsApp"
}'
Example — Change Status (default reason)
curl -X PUT "https://wegocod.com/api/v1/orders/ORD-000850" \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"shipping_status": "returned"
}'
When no reason is provided, the status history will show through api as the default reason.
Status Flow
Orders follow a strict status flow. You can only transition forward.
| Current Status | Allowed Next |
|---|---|
| pending | picked_up |
| picked_up | preparing |
| preparing | prepared |
| prepared | out_for_delivery |
| out_for_delivery | delivered returned |
| delivered | Final |
| returned | return_received delivered |
| return_received | returned_to_stock |
Error Codes
| Code | Meaning |
|---|---|
| 401 | Unauthorized — invalid or missing API token |
| 403 | Forbidden — no access to this resource |
| 404 | Not Found — order doesn't exist |
| 422 | Validation Error — check errors field |
| 429 | Rate Limited — wait and retry |
| 500 | Server Error — contact admin |
Error Response Format
{
"status": "error",
"message": "Validation failed",
"errors": {
"recipient_name": ["The recipient name field is required."],
"items": ["The items field is required."]
}
}