---
# System prepended metadata

title: Fulfil.hr API

---

# Fulfil.hr API

## Authentication API

There are 2 options of authentication. 
1. With an API key
2. With JWT on /api/token/ and /api/token/refresh/ using fields `username` and `password`.

## Order API

### /api/order/
- GET method
    Returns a list of all existing orders for the authenticated user. All results are ordered by their creation date ($1^{st}$ is the most recent order)
    Available query parameters:
    * start: lists all orders that were submited after (inclusively) the start date (UNIX timestamp). Default: blank -> since the begining
    * end: lists all orders that were submited before (inclusevly) the end date (UNIX timestamp). Default: blank -> till now

    Example: 
    GET request: `curl https://fulfil.hr/api/order/?start=1400000000&end=1500000000`
    GET response: 
    ```
    {
      "orders": [
        {
          "id": "8e9d537d-b1a9-4fb0-b69e-6bf98bf599ff",
          "order_id": "#123456789",
          "status": "accepted"
        },
        {
          "id": "100838ef-da55-42c6-a873-8e18a8d76782",
          "order_id": "#123456788",
          "status": "shipped"
        }
      ]
    }
    ```

- POST method
    Accepts the order details.
    Payload data:
    ```
    {
      "order_id": "#YourInternalOrderID",
      "address": {
        "full_name": "John Doe",
        "street_name": "Doey Street",
        "street_number": "8",
        "city": "Johnburg",
        "zip": "10000",
        "country": "The Country"
      },
      "items": [
        {
          "product": "12345679", // Product ID
          "quantity": 5
        },
        {
          "product": "12345678",
          "quantity": 5
        }
      ],
      "invoice": "https://yoursite.com/invoices/YourInternalOrderID.pdf", // May be blank
      "price": 15.3,
      "currency": "EUR"
      "cash_on_delivery": true

    }
    ```
    
    Response data:
    ```
    {
      "id": "a1824d41-a343-47cd-8906-b0ed1bebc74a",
      "order_id": "#YourInternalOrderID",
      "address": {
        "full_name": "John Doe",
        "street_name": "Doey Street",
        "street_number": "8",
        "city": "Johnburg",
        "zip": "10000",
        "country": "The Country"
      },
      "items": [
        {
          "product": "12345679", // Product ID
          "quantity": 5
        },
        {
          "product": "12345678",
          "quantity": 5
        }
      ],
      "status": "accepted",
      "invoice": "https://yoursite.com/invoices/YourInternalOrderID.pdf", // "" if blank
      "price": 15.3,
      "currency": "EUR"
      "cash_on_delivery": true,
      "Errors": [
        "Some descriptive error. This list is skipped if no error is returned."
      ]

    }
    ```

### /api/order/{id}
- GET method
    This API endpoint is used to get details about order. Instead of {id} in the URL, use order ID ("id").
    Response:
    ```
    {
      "id": "a1824d41-a343-47cd-8906-b0ed1bebc74a",
      "order_id": "#YourInternalOrderID",
      "address": {
        "full_name": "John Doe",
        "street_name": "Doey Street",
        "street_number": "8",
        "city": "Johnburg",
        "zip": "10000",
        "country": "The Country"
      },
      "items": [
        {
          "product": "12345679", // Product ID
          "quantity": 5
        },
        {
          "product": "12345678",
          "quantity": 5
        }
      ],
      "status": "accepted",
      "invoice": "https://fulfil.hr/invoices/a1824d41-a343-47cd-8906-b0ed1bebc74a.pdf, // "" if blank
      "price": 15.3,
      "currency": "EUR"
      "cash_on_delivery": true,
      "status_changes": [
        {
          "from": "none",
          "to": "accepted",
          "timestamp": 1500000000
        },
        {
          "from": "accepted",
          "to": "shipped",
          "timestamp": 1500010000
        },
        {
          "from": "shipped",
          "to": "delivered",
          "timestamp": 1500020000
        }
      ]

    }
    ```

## Stock API

### /api/stock/
- GET method
    Returns a list of all products and their stock state.
    Available query parameter:
    * product_id: ID of the product in your store
    * id: ID of the product in fulfil.


    Paramerters are mutualy exclusive.
    Example: `curl https://fulfil.hr/api/stock/`
    ```
    {
      "products": [
        {
          "id": "8e9d537d-b1a9-4fb0-b69e-6bf98bf599ff",
          "product_id": "123456",
          "product_name": "The product",
          "on_stock": 1234
        },
        {
          "id": "100838ef-da55-42c6-a873-8e18a8d76782",
          "product_id": "123457",
          "product_name": "The other product",
          "on_stock": 1243
        }
      ]
    }
    ```
    
    Example: `curl https://fulfil.hr/api/stock/?id=8e9d537d-b1a9-4fb0-b69e-6bf98bf599ff`
    ```
    {
      "products": [
        {
          "id": "8e9d537d-b1a9-4fb0-b69e-6bf98bf599ff",
          "product_id": "123456",
          "product_name": "The product",
          "on_stock": 1234
        }
      ]
    }
    ```
    
    Example: `curl https://fulfil.hr/api/stock/?product_id=123456`
    ```
    {
      "products": [
        {
          "id": "8e9d537d-b1a9-4fb0-b69e-6bf98bf599ff",
          "product_id": "123456",
          "product_name": "The product",
          "on_stock": 1234
        }
      ]
    }
    ```
    
