Tier 0 Product1
API reference

API Reference

Complete REST API endpoint documentation


Description

The pycli REST API lets you create, retrieve, list, and cancel orders programmatically over HTTP. Use these endpoints to integrate order management into your own applications or automate workflows that would otherwise require manual interaction through the CLI.


Parameters

Parameters vary by endpoint. See the per-endpoint tables below.


GET /orders/{order_id} — Fetch a single order

ParameterTypeRequiredDescription
order_idintegerYesThe unique numeric ID of the order to retrieve. Passed as a path segment.

POST /orders — Create an order

Send a JSON body with the following fields:

ParameterTypeRequiredDescription
amountintegerYesThe order amount, expressed as a whole number (e.g., in the smallest unit of the currency).
currencystringYesThe ISO 4217 currency code for the order (e.g., "USD", "EUR").
notestringNoAn optional free-text note to attach to the order. Omit or set to null if not needed.

GET /orders — List orders

ParameterTypeRequiredDescription
statusstringNoFilter orders by status. Defaults to "paid" if omitted.
limitintegerNoMaximum number of orders to return. Defaults to 20 if omitted.

DELETE /orders/{order_id} — Cancel an order

ParameterTypeRequiredDescription
order_idintegerYesThe unique numeric ID of the order to cancel. Passed as a path segment.

Returns

All successful responses use HTTP 200 OK and return JSON.


GET /orders/{order_id}

Returns a single order object:

{
  "id": 42,
  "amount": 100,
  "currency": "USD",
  "status": "paid"
}
FieldTypeDescription
idintegerThe order's unique identifier.
amountintegerThe order amount.
currencystringThe currency code for the order.
statusstringThe current status of the order (e.g., "paid", "pending", "canceled").

POST /orders

Returns the newly created order object with an assigned id and a status of "pending":

{
  "id": 1,
  "amount": 250,
  "currency": "EUR",
  "status": "pending"
}

GET /orders

Returns a JSON object containing the applied filter parameters and an array of matching orders:

{
  "status": "paid",
  "limit": 20,
  "orders": []
}
FieldTypeDescription
statusstringThe status filter that was applied.
limitintegerThe limit that was applied.
ordersarrayThe list of matching order objects.

DELETE /orders/{order_id}

Returns a confirmation object showing the order ID and its updated status:

{
  "id": 42,
  "status": "canceled"
}

Errors

The API returns standard HTTP error codes when a request cannot be completed.

ErrorHTTP StatusWhen it occurs
Validation Error422 Unprocessable EntityThe request body or parameters fail validation — for example, sending a string where an integer is required, or omitting a required field such as amount or currency in POST /orders. The response body includes a detail array describing each validation failure.
Not Found404 Not FoundThe requested order_id does not exist.
Method Not Allowed405 Method Not AllowedYou used an HTTP method that is not supported for the given endpoint (e.g., PUT /orders).
Internal Server Error500 Internal Server ErrorAn unexpected server-side error occurred. Retry the request or contact support if the issue persists.

Examples

The examples below use curl. Replace https://api.example.com with your actual base URL.


Fetch a single order by ID

curl -X GET https://api.example.com/orders/42

Expected response:

{
  "id": 42,
  "amount": 100,
  "currency": "USD",
  "status": "paid"
}

Create a new order

curl -X POST https://api.example.com/orders \
  -H "Content-Type: application/json" \
  -d '{"amount": 250, "currency": "EUR", "note": "Rush delivery"}'

Expected response:

{
  "id": 1,
  "amount": 250,
  "currency": "EUR",
  "status": "pending"
}

Create an order without an optional note

curl -X POST https://api.example.com/orders \
  -H "Content-Type: application/json" \
  -d '{"amount": 500, "currency": "USD"}'

Expected response:

{
  "id": 1,
  "amount": 500,
  "currency": "USD",
  "status": "pending"
}

List orders filtered by status

curl -X GET "https://api.example.com/orders?status=pending&limit=5"

Expected response:

{
  "status": "pending",
  "limit": 5,
  "orders": []
}

Cancel an order

curl -X DELETE https://api.example.com/orders/42

Expected response:

{
  "id": 42,
  "status": "canceled"
}

Example of a validation error (missing required field)

curl -X POST https://api.example.com/orders \
  -H "Content-Type: application/json" \
  -d '{"currency": "USD"}'

Expected response (422 Unprocessable Entity):

{
  "detail": [
    {
      "loc": ["body", "amount"],
      "msg": "field required",
      "type": "value_error.missing"
    }
  ]
}

Notes
  • amount is an integer. The API represents monetary amounts as whole numbers. Decide on a convention with your team — for example, storing cents rather than dollars — and apply it consistently across all requests. Sending a floating-point value (e.g., 9.99) will result in a 422 validation error.
  • Query parameter defaults. When you call GET /orders without specifying status or limit, the API automatically applies status=paid and limit=20. Always pass these parameters explicitly in production code to avoid unintended filtering behavior.
  • note is truly optional. You may omit the note field entirely from the POST /orders request body, or include it with a null value — both are valid.
  • Path parameters must be integers. Both GET /orders/{order_id} and DELETE /orders/{order_id} require order_id to be a valid integer. Passing a non-numeric value (e.g., /orders/abc) will result in a 422 validation error.
  • Authentication. The source code does not define any authentication mechanism. Consult your deployment configuration or contact your infrastructure team to determine what authentication headers or tokens (if any) are required in your environment.
  • DELETE is not reversible. Canceling an order via DELETE /orders/{order_id} sets its status to "canceled". There is no undo endpoint — verify the correct order_id before sending this request.