API v1, Live

Orders API Documentation

Complete REST API reference for managing orders, fetch, create, update, and track order statuses programmatically.

Bearer Token Auth
60 req/min
JSON responses
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

ParameterTypeDescription
statusstring optionalFilter by shipping status
fromdate optionalStart date (YYYY-MM-DD)
todate optionalEnd date (YYYY-MM-DD)
citystring optionalFilter by city
countrystring optionalCountry code (MA)
sort_bystring optionalSort: created_at, amount, shipping_status
sort_dirstring optionalDirection: asc or desc
per_pageinteger optionalResults 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

FieldTypeDescription
recipient_namestring requiredCustomer full name
phonestring requiredPhone number (+212...)
addressstring requiredDelivery address
citystring requiredDelivery city (must match Forcelog cities)
countrystring requiredMA
delivery_notesstring optionalNotes for delivery driver
itemsarray requiredProduct items (min 1)
items[].product_idinteger requiredProduct ID
items[].quantityinteger requiredQuantity (min 1)
items[].pricenumber optionalCustom 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)

FieldTypeDescription
recipient_namestringUpdate customer name
phonestringUpdate phone number
addressstringUpdate delivery address
citystringUpdate city
delivery_notesstringUpdate delivery notes
shipping_statusstringChange status (must follow valid flow)
reasonstringReason 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 StatusAllowed Next
pendingpicked_up
picked_uppreparing
preparingprepared
preparedout_for_delivery
out_for_deliverydelivered returned
deliveredFinal
returnedreturn_received delivered
return_receivedreturned_to_stock
Error Codes
CodeMeaning
401Unauthorized, invalid or missing API token
403Forbidden, no access to this resource
404Not Found, order doesn't exist
422Validation Error, check errors field
429Rate Limited, wait and retry
500Server 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."]
  }
}