API Requests Reference

The Cyke API allows you to either list your deliveries, create a delivery, get a delivery, edit a delivery or cancel a delivery.

List package types

Endpoint

GET /api/v2/package_types

URL Parameters

None.

Code examples

Request

curl --location --request GET '<URL>/api/v2/package_types' \
  --header 'X-User-Email: victor@my_company.com' \
  --header 'X-User-Token: G6RNXfdNaPPh3DtMYAR8' \
  --data-raw ''

Response

[
  {
    "id": 1,
    "type": "Carton de 12 bières 33cl",
    "volume": 4,
    "weight": 6,
    "fragility": "fragile",
    "temperature": null
  },
  ...
  {
    "id": 5,
    "type": "Fûts inox de 20L",
    "volume": 25,
    "weight": 30,
    "fragility": null,
    "temperature": null
  }
]

List deliveries

Endpoint

GET /api/v2/deliveries

URL Parameters

Parameter Type Examples Description
client_order_reference string client_order_reference=PO5EF29A Filter deliveries having a specific client order reference.

Code examples

Request

curl --location --request GET '<URL>/api/v2/deliveries' \
  --header 'X-User-Email: victor@my_company.com' \
  --header 'X-User-Token: G6RNXfdNaPPh3DtMYAR8' \
  --data-raw ''

If you want to apply specific filters:

curl --location --request GET '<URL>/api/v2/deliveries?client_order_reference=POE5F29A' \
  --header 'X-User-Email: victor@my_company.com' \
  --header 'X-User-Token: G6RNXfdNaPPh3DtMYAR8' \
  --data-raw ''

Response

[
  {
    "id": 1,
    "created_at": "2020-07-25T11:50:00.000+02:00",
    "status": "delivered",
    "slot_starting_at": "2020-08-01T11:00:00.000+02:00",
    "slot_ending_at": "2020-08-01T13:00:00.000+02:00",
    "price_cents": null
  },
  ...
  {
    "id": 86,
    "created_at": "2020-11-09T10:00:00.000+02:00",
    "status": "scheduled",
    "slot_starting_at": "2020-11-09T16:00:00.000+02:00",
    "slot_ending_at": "2020-11-09T18:00:00.000+02:00",
    "price_cents": null
  }
]

Create a delivery

Endpoint

POST /api/v2/deliveries

Code examples

Request

curl --location --request POST '<URL>/api/v2/deliveries/' \
--header 'X-User-Email: victor@my_company.com' \
--header 'X-User-Token: G6RNXfdNaPPh3DtMYAR8' \
--header 'Content-Type: application/json' \
--data-raw '{
"dropoff": {
  "slot_starting_at": "2020-11-09T16:00:00.000+02:00",
  "slot_ending_at": "2020-11-09T18:00:00.000+02:00",
  "place": {
    "recipient_name": "Cercei Lannister",
    "recipient_phone": "+33670707070",
    "company_name": "Lannister Inc.",
    "address": "1 place du Palais Royal",
    "postal_code": "75001",
    "city": "Paris",
    "address_instructions": "digicode 3495 au fond à gauche"
  }
},
"packages": [
    {
      "name": "Carton de 12 bières 33cl",
      "amount": 3,
      "volume_dm3": 4,
      "weight_kg": 6,
      "fragility": null,
      "temperature": null,
      "client_reference": "1234"
    },
    {
      "package_type_id": 5,
      "amount": 1
    }
],
"comments": "Fûts de blonde, faire attention à la DLUO",
"client_order_reference": "POE5F29A",
"bring_back_containers": false
}'
require "uri"
require "net/http"
require "json"

url = URI("https://<URL>/api/v2/deliveries")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)

request["X-User-Email"] = "victor@my_company.com"
request["X-User-Token"] = "G6RNXfdNaPPh3DtMYAR8"
request["Content-Type"] = "application/json"

delivery = {
  "dropoff": {
    "slot_starting_at": "2020-11-09T16:00:00.000+02:00",
    "slot_ending_at": "2020-11-09T18:00:00.000+02:00",
    "place": {
      "recipient_name": "Cercei Lannister",
      "recipient_phone": "+33670707070",
      "company_name": "Lannister Inc.",
      "address": "1 place du Palais Royal",
      "postal_code": "75001",
      "city": "Paris",
      "address_instructions": "digicode 3495 au fond à gauche"
    }
  },
  "packages": [
    {
      "name": "Carton de 12 bières 33cl",
      "amount": 3,
      "volume_dm3": 4,
      "weight_kg": 6,
      "fragility": null,
      "temperature": null,
      "client_reference": "1234",
    },
    {
      "package_type_id": 5,
      "amount": 1
    }
  ],
  "comments": "Fûts de blonde, faire attention à la DLUO",
  "client_order_reference": "POE5F29A",
  "bring_back_containers": false
}

request.body = delivery.to_json

response = https.request(request)

puts response.read_body

Response

Returns the created Delivery with an http status of 201 (Created). See Get a delivery response.

If there is an error during the delivery creation, it will be returned instead of the delivery, and the http status will be 422 (Unprocessable Entity).

For example:

{
  "errors": [
    "Packages Unknown type"
  ]
}

Get a delivery

Endpoint

GET /api/v2/deliveries/<DELIVERY_ID>

Code examples

Request

curl --location --request GET '<URL>/api/v2/deliveries/86' \
--header 'X-User-Email: victor@my_company.com' \
--header 'X-User-Token: G6RNXfdNaPPh3DtMYAR8' \
--data-raw ''

Response

{
  "id": 86,
  "created_at": "2020-11-09T10:00:00.000+02:00",
  "status": "saved",
  "comments": "Fûts de blonde, faire attention à la DLUO",
  "client_order_reference": "POE5F29A",
  "price_cents": null,
  "direction": "outbound",
  "bring_back_containers": false,
  "original_delivery_id": null,
  "redelivery_id": null,
  "dropoff": {
    "slot_starting_at": "2020-11-09T16:00:00.000+02:00",
    "slot_ending_at": "2020-11-09T18:00:00.000+02:00",
    "tracking_url": null,
    "completed_at": null,
    "failure_reason": null,
    "notes": null,
    "completion_signature": null,
    "completion_pictures": [],
    "place": {
      "recipient_name": "Cercei Lannister",
      "recipient_phone": "+32 470 70 70 70",
      "company_name": "Lannister Inc.",
      "address": "1 place du Palais Royal",
      "postal_code": "75001",
      "city": "Paris",
      "address_instructions": "digicode 3495 au fond à gauche"
    }
  },
  "packages": [
    {
      "package_type_id": null,
      "type": "Carton de 12 bières 33cl",
      "name": "Carton de 12 bières 33cl",
      "amount": 3,
      "volume_dm3": 4,
      "weight_kg": 6,
      "fragility": null,
      "temperature": null,
      "client_reference": "1234"
    },
    {
      "package_type_id": 5,
      "type": "Thermobox",
      "name": "Thermobox",
      "amount": 1,
      "volume_dm3": 20,
      "weight_kg": 10,
      "fragility": null,
      "temperature": "fresh",
      "client_reference": null
    }
  ],
  "reversed_packages": []
}

Get the latest delivery

This endpoint retrieves the latest delivery for the given filters.

Endpoint

GET /api/v2/deliveries/latest

URL Parameters

Parameter Type Examples Description
client_order_reference string client_order_reference=PO5EF29A Filter deliveries having a specific client order reference.

Code examples

Request

curl --location --request GET '<URL>/api/v2/deliveries/latest' \
--header 'X-User-Email: victor@my_company.com' \
--header 'X-User-Token: G6RNXfdNaPPh3DtMYAR8' \
--data-raw ''

If you want to apply specific filters:

curl --location --request GET '<URL>/api/v2/deliveries/latest?client_order_reference=POE5F29A' \
--header 'X-User-Email: victor@my_company.com' \
--header 'X-User-Token: G6RNXfdNaPPh3DtMYAR8' \
--data-raw ''

Response

Returns the updated Delivery with an http status of 200 (Created). See Get a delivery response.

Update a delivery

Endpoint

PATCH /api/v2/deliveries/<DELIVERY_ID>
PUT /api/v2/deliveries/<DELIVERY_ID>

Code examples

Request

curl --location --request PUT '<URL>/api/v2/deliveries/<DELIVERY_ID>' \
--header 'X-User-Email: victor@my_company.com' \
--header 'X-User-Token: G6RNXfdNaPPh3DtMYAR8' \
--header 'Content-Type: application/json' \
--data-raw '{
"dropoff": {
  "slot_starting_at": "2020-11-09T16:30:00.000+02:00"
  }
}'
require "uri"
require "net/http"
require "json"

url = URI("https://<URL>/api/v2/deliveries/<DELIVERY_ID>")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Put.new(url)

request["X-User-Email"] = "victor@my_company.com"
request["X-User-Token"] = "G6RNXfdNaPPh3DtMYAR8"
request["Content-Type"] = "application/json"

delivery = {
  "dropoff": {
    "slot_starting_at": "2020-11-09T16:30:00.000+02:00"
  },
}

request.body = delivery.to_json

response = https.request(request)

puts response.read_body

Response

Returns the updated Delivery with an http status of 200 (Created). See Get a delivery response.

If there is an error during the delivery update, it will be returned instead of the delivery, and the http status will be 422 (Unprocessable Entity).

For example:

{
  "errors": [
    "Packages Unknown type"
  ]
}

Cancel a delivery

Endpoint

PATCH /api/v2/deliveries/<DELIVERY_ID>/cancel

Code examples

Request

curl --location --request PATCH '<URL>/api/v2/deliveries/<DELIVERY_ID>/cancel' \
--header 'X-User-Email: victor@my_company.com' \
--header 'X-User-Token: G6RNXfdNaPPh3DtMYAR8' \
--header 'Content-Type: application/json'
require "uri"
require "net/http"
require "json"

url = URI("https://<URL>/api/v2/deliveries/<DELIVERY_ID>")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Patch.new(url)

request["X-User-Email"] = "victor@my_company.com"
request["X-User-Token"] = "G6RNXfdNaPPh3DtMYAR8"
request["Content-Type"] = "application/json"

response = https.request(request)

puts response.read_body

Response

Returns the canceled Delivery with an http status of 200 (Created). See Get a delivery response.

If there is an error during the delivery cancellation, it will be returned instead of the delivery, and the http status will be 422 (Unprocessable Entity).

For example:

{
  "errors": [
    "Packages Unknown type"
  ]
}