Make Your First API Call

The Carriyo API supports OAuth2.0 authentication. To access any Carriyo API, you must first obtain an OAuth access token.

Step 1: Request an Access Token

This authentication endpoint accepts your client_id and client_secret, and returns an access token. The access token should be used as a bearer token in the Authorization header for any subsequent Carriyo API calls.

PLEASE NOTE: You must cache the access token on the client side until its expiry.

Use the cURL command below, replacing the following values:

  • YOUR-CLIENT-ID
  • YOUR-CLIENT-SECRET
Copy
Copied
curl --location --request POST 'https://api.carriyo.com/oauth/token' \
--header 'Content-Type: application/json' \
--data-raw '{
    "client_id": "YOUR-CLIENT-ID",
    "client_secret": "YOUR-CLIENT-SECRET"
}'
Authentication Steps Complete

You now have the credentials to make your first API call

Step 2. Make an API Request

Once you have the access token, you can use the cURL command below, replacing these values:

  • YOUR-TENANT-ID
  • YOUR-MERCHANT-ID
  • YOUR-API-KEY
  • YOUR-ACCESS-TOKEN

Alternatively, you can use the "Try It" console to create your first shipment. Click here to see use the 'Try It' console

Copy
Copied
curl --location --request POST 'https://api.carriyo.com/shipments?draft=true' \
--header 'Content-Type: application/json' \
--header 'x-api-key: YOUR-API-KEY' \
--header 'tenant-id: YOUR-TENANT-ID' \
--header 'Authorization: Bearer YOUR-ACCESS-TOKEN' \
--data-raw '{
    "merchant": "YOUR-MERCHANT-ID",
    "references": {
        "partner_order_reference": "test-order-1",
        "partner_shipment_reference": "test-shipment-1"
    },
    "payment": {
        "payment_mode": "PRE_PAID",
        "total_amount": 100.0,
        "currency": "USD"
    },
    "items": [
        {
            "description": "Awesome t-shirt",
            "quantity": 1,
            "price": {
                "amount": 100.0,
                "currency": "USD"
            },
            "sku": "S12345"
        }
    ],
    "dropoff": {
        "contact_name": "Joe Bloggs",
        "contact_phone": "+18005550123",
        "contact_email": "customer@example.com",
        "address1": "1234 Elm Street",
        "city": "San Francisco",
        "state": "CA",
        "country": "US",
        "postcode": "94103",
        "coords": [
            37.7749,
            -122.4194
        ]
    }
}'