Orders

Order

An Order is the process of buying a Custom Product. The desired product(s) must already be configured.

Get an order

To get orders from your account use the following endpoint:

GET https://api.safsira.com/v1/orders

You can also retrieve orders by providing an id:

GET https://api.safsira.com/v1/orders/:id

Create an order

To create an order, first you need to get your Custom Product data by calling the Custom Products endpoint. From there, you will need the id of the product and the attributes to specify the particular Product Part(s) you want to order. You will also need the payment_method_id to specify the payment method you want to use. You can get the payment methods by calling the payment methods endpoint.

To create an order use the following endpoint:

POST https://api.safsira.com/v1/orders/

The request body should look something like the following:

{
    "external_id": "qwerty12345",
    "payment_method_id": "pm_ABCDEFGHIJKLMNOPQRSTUVWX",
    "billing_address": {
        "first_name": "John",
        "last_name": "Doe",
        "email": "john.doe@safsira.com",
        "phone": "+13022087150",
        "company": "Safsira",
        "line_1": "1209 N Orange St",
        "city": "Wilmington",
        "state": "DE",
        "postal_code": "19801",
        "country": "US"
    },
    "line_items": [
        {
            "id": 1,
            "product": 5827,
            "quantity": 1,
            "attributes": {
                "size": "L",
                "color": "Vintage White"
            }
        }
    ],
    "shipping_orders": [
        {
            "recipient": {
                "first_name": "John",
                "last_name": "Doe",
                "email": "john.doe@safsira.com",
                "phone": "+13022087150",
                "company": "Safsira",
                "line_1": "29707 Hancock Parkway",
                "city": "Valencia",
                "state": "CA",
                "postal_code": "91355",
                "country": "US"
            },
            "line_items": [
                {
                    "id": 1,
                    "quantity": 1
                }
            ]
        }
    ]
}

In this request, line_items represent the products to be ordered, while shipping_orders represent the associated shipping orders (i.e. shipments). You can have multiple shipments if you want to ship products to different addresses. The products will be shipped as soon as possible.

As you can see, each line_item has an id, a product id, a quantity and attributes. This id is the id of the line item that will be used as reference on the shipping_orders. The product id is the id of the product to be ordered, while quantity indicates order quantity. You can get the attributes by calling the Custom Products endpoint and looking at the available_attributes field.

ℹ️

The billing_address field is not required if you have a default billing address in your account. The order will use the request's billing_address if present, otherwise it will use the default billing address in your account.

The shipping_orders list holds every shipment associated with this order. These shipping orders each have a recipient, and a line_items list. The recipient is the intended delivery address. The line_items list holds the products and quantity breakdown for this delivery address. Please note that you are not using a product id here, but rather an id which is a reference to a line_item within the same payload. Every line_item must be accounted for in the shipping_orders.

The external_id is an optional (but highly recommended) parameter that we encourage you to use to keep track of your orders. Generally, this is the end-user's order number or reference from your own platform, but it can be any string you want that uniquely identifies the order.