Skip to content

Endpoints

Attention

To consume the API, the user must be authenticated.

POST /orders

Create a new order for the current user.

{
    "items": [
        {
            "idProduct": "0195abfb-7074-73a9-9d26-b4b9fbaab0a8",
            "quantity": 2
        },
        {
            "idProduct": "0195abfe-e416-7052-be3b-27cdaf12a984",
            "quantity": 1
        }
    ]
}

{
    "id": "0195ac33-73e5-7cb3-90ca-7b5e7e549569",
    "date": "2025-09-01T12:30:00",
    "items": [
        {
            "id": "01961b9a-bca2-78c4-9be1-7092b261f217",
            "product": {
                "id": "0195abfb-7074-73a9-9d26-b4b9fbaab0a8"
            },
            "quantity": 2,
            "total": 20.24
        },
        {
            "id": "01961b9b-08fd-76a5-8508-cdb6cd5c27ab",
            "product": {
                "id": "0195abfe-e416-7052-be3b-27cdaf12a984"
            },
            "quantity": 1,
            "total": 0.62
        }
    ],
    "total": 20.86
}
Response code: 201 (created)
Response code: 400 (bad request), if the product does not exist.

GET /orders

Get all orders for the current user.

[
    {
        "id": "0195ac33-73e5-7cb3-90ca-7b5e7e549569",
        "date": "2025-09-01T12:30:00",
        "total": 26.44
    },
    {
        "id": "0195ac33-cbbd-7a6e-a15b-b85402cf143f",
        "date": "2025-10-09T03:21:57",
        "total": 18.6
    }

]
Response code: 200 (ok)

GET /orders/{id}

Get the order details by its ID. The order must belong to the current user., otherwise, return a 404.

An optional query parameter currency allows the totals to be returned in a different currency. When omitted, values are returned in USD (the database storage currency).

Currency storage

All monetary values are stored in the database in US Dollars (USD). When a currency parameter is provided, the service must call the Exchange API to convert the totals before returning the response.

{
    "id": "0195ac33-73e5-7cb3-90ca-7b5e7e549569",
    "date": "2025-09-01T12:30:00",
    "currency": "USD",
    "items": [
        {
            "id": "01961b9a-bca2-78c4-9be1-7092b261f217",
            "product": {
                "id": "0195abfb-7074-73a9-9d26-b4b9fbaab0a8",
            },
            "quantity": 2,
            "total": 20.24
        },
        {
            "id": "01961b9b-08fd-76a5-8508-cdb6cd5c27ab",
            "product": {
                "id": "0195abfe-e416-7052-be3b-27cdaf12a984"
            },
            "quantity": 1,
            "total": 0.62
        }
    ],
    "total": 20.86
}
Response code: 200 (ok)
Response code: 404 (not found), if the order does not belong to the current user.

{
    "id": "0195ac33-73e5-7cb3-90ca-7b5e7e549569",
    "date": "2025-09-01T12:30:00",
    "currency": "BRL",
    "items": [
        {
            "id": "01961b9a-bca2-78c4-9be1-7092b261f217",
            "product": {
                "id": "0195abfb-7074-73a9-9d26-b4b9fbaab0a8",
            },
            "quantity": 2,
            "total": 121.44
        },
        {
            "id": "01961b9b-08fd-76a5-8508-cdb6cd5c27ab",
            "product": {
                "id": "0195abfe-e416-7052-be3b-27cdaf12a984"
            },
            "quantity": 1,
            "total": 3.72
        }
    ],
    "total": 125.16
}
Response code: 200 (ok)
Response code: 404 (not found), if the order does not belong to the current user.
Response code: 422 (unprocessable entity), if the currency code is not supported.