> For the complete documentation index, see [llms.txt](https://wemx.gitbook.io/wemx-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wemx.gitbook.io/wemx-api/api-reference/orders.md).

# Orders

## Get all orders

<mark style="color:blue;">`GET`</mark> `https://wemx.app/api/v1/orders`

Returns all orders on your application

{% tabs %}
{% tab title="200: OK " %}

```json
{
    "status": true,
    "current_page": 1,
    "data": [
        {
            "id": 2,
            "user_id": 2388,
            "package_id": 1,
            "status": "active",
            "name": "Your personal server",
            "service": "universal",
            "domain": null,
            "price": {
                "id": 2,
                "package_id": 2,
                "type": "single",
                "period": 90,
                "price": 333,
                "renewal_price": 333,
                "setup_fee": 0,
                "cancellation_fee": 0,
                "data": null,
                "is_active": 1,
                "created_at": "2024-01-09T19:22:17.000000Z",
                "updated_at": "2024-01-09T19:22:26.000000Z"
            },
            "options": {
                "coupon": null
            },
            "data": {
                "example": true
            },
            "notes": null,
            "cancelled_at": null,
            "cancel_reason": null,
            "last_renewed_at": "2024-01-09T19:29:59.000000Z",
            "due_date": "2025-04-17T00:00:00.000000Z",
            "created_at": "2024-01-09T18:29:25.000000Z",
            "updated_at": "2024-01-09T19:29:59.000000Z"
        }
    ],
    "first_page_url": "http://wemx.app/api/v1/orders?page=1",
    "from": 1,
    "last_page": 1,
    "last_page_url": "http://wemx.app/api/v1/orders?page=1",
    "links": [
        {
            "url": null,
            "label": "Previous",
            "active": false
        },
        {
            "url": "http://wemx.app/api/v1/orders?page=1",
            "label": "1",
            "active": true
        },
        {
            "url": null,
            "label": "Next",
            "active": false
        }
    ],
    "next_page_url": null,
    "path": "http://wemx.app/api/v1/orders",
    "per_page": 15,
    "prev_page_url": null,
    "to": 2,
    "total": 2
}
```

{% endtab %}
{% endtabs %}

### Available Relationships (optional)

```
https://wemx.app/api/v1/orders?include=user,payments,package
```

#### Available relationships:

`user`, `payments`, `package`, `members`

## Filters (optional)

```
https://wemx.app/api/v1/orders?filter[status]=suspended
```

#### Available Filters:

`package_id`, `status`, `service`, `domain`, `data`, `options`, `price` `due_date`

Tip: To filter JSON columns such as data and options, you can specify the key using \
`?filter[data->server_id]=12`

## Sorting (optional)

```
https://wemx.app/api/v1/orders?sort[created_at]=asc
```

#### Available Sorting Parameters:

`first_name`, `last_name`, `username`, `email`, `balance`, `created_at`

#### Sorting operators

`asc`, `desc`, `random`

## Dates (optional)

```
https://wemx.app/api/v1/orders?date=30days
```

<table><thead><tr><th width="390">Operator</th><th>Description</th></tr></thead><tbody><tr><td>today</td><td>Get orders created today</td></tr><tr><td>yesterday</td><td>Get orders created yesterday</td></tr><tr><td><code>3days</code>, <code>7days</code>, <code>14days</code>, <code>30days</code>, <code>90days</code></td><td>Get orders created last x days</td></tr><tr><td>YYYY-MM-DD,YYY-MM-DD</td><td>Get orders created between a range of dates</td></tr></tbody></table>

## Get an order

<mark style="color:blue;">`GET`</mark> `https://wemx.app/api/v1/orders/{order}`

Retrieves a single order from the order id

#### Query Parameters

| Name     | Type   | Description      |
| -------- | ------ | ---------------- |
| package  | String | Include package  |
| members  | String | Include members  |
| payments | String | Include payments |
| user     | String | Include user     |

{% tabs %}
{% tab title="200: OK " %}

```json
{
    "status": true,
    "data": {
        "id": 2,
        "user_id": 2388,
        "package_id": 1,
        "status": "active",
        "name": "Your personal server",
        "service": "universal",
        "domain": null,
        "price": {
            "id": 2,
            "package_id": 2,
            "type": "single",
            "period": 90,
            "price": 333,
            "renewal_price": 333,
            "setup_fee": 0,
            "cancellation_fee": 0,
            "data": null,
            "is_active": 1,
            "created_at": "2024-01-09T19:22:17.000000Z",
            "updated_at": "2024-01-09T19:22:26.000000Z"
        },
        "options": {
            "coupon": null
        },
        "data": {
            "example": true
        },
        "notes": null,
        "cancelled_at": null,
        "cancel_reason": null,
        "last_renewed_at": "2024-01-09T19:29:59.000000Z",
        "due_date": "2025-04-17T00:00:00.000000Z",
        "created_at": "2024-01-09T18:29:25.000000Z",
        "updated_at": "2024-01-09T19:29:59.000000Z"
    }
}
```

{% endtab %}
{% endtabs %}

## Update an order

<mark style="color:orange;">`PUT`</mark> `https://wemx.app/api/v1/orders/{order}`

Update a specific order. All parameters are optional, only pass the parameters that you wish to update

#### Request Body

| Name      | Type   | Description                                                   |
| --------- | ------ | ------------------------------------------------------------- |
| name      | String | Name of the order                                             |
| user\_id  | Number | Change the user that owns the order                           |
| price\_id | Number | Change the price of the order                                 |
| data      | JSON   | Update the data parameters of an order                        |
| options   | JSON   | Update the options of an order                                |
| due\_date | Date   | Change the due date of an order, must be a date in the future |

{% tabs %}
{% tab title="200: OK " %}

```json
{
    "success": true,
    "data": {
        "id": 2,
        "user_id": 2388,
        "package_id": 1,
        "status": "active",
        "name": "Your personal server",
        "service": "universal",
        "domain": null,
        "price": {
            "id": 2,
            "package_id": 2,
            "type": "single",
            "period": 90,
            "price": 333,
            "renewal_price": 333,
            "setup_fee": 0,
            "cancellation_fee": 0,
            "data": null,
            "is_active": 1,
            "created_at": "2024-01-09T19:22:17.000000Z",
            "updated_at": "2024-01-09T19:22:26.000000Z"
        },
        "options": {
            "coupon": null
        },
        "data": {
            "example": true
        },
        "notes": null,
        "cancelled_at": null,
        "cancel_reason": null,
        "last_renewed_at": "2024-01-09T19:29:59.000000Z",
        "due_date": "2025-04-17T00:00:00.000000Z",
        "created_at": "2024-01-09T18:29:25.000000Z",
        "updated_at": "2024-01-09T19:29:59.000000Z"
    }
}
```

{% endtab %}
{% endtabs %}

## Delete an order

<mark style="color:red;">`DELETE`</mark> `https://wemx.app/api/v1/orders/{order}`

Delete a order, the order must be terminated in order to delete it. Pass "force=1" to ignore this check

#### Request Body

| Name  | Type    | Description             |
| ----- | ------- | ----------------------- |
| force | boolean | Delete order forcefully |

{% tabs %}
{% tab title="200: OK " %}

{% endtab %}
{% endtabs %}

## Suspend an order

<mark style="color:green;">`POST`</mark> `https://wemx.app/api/v1/orders/{order}/suspend`

Suspend an order using from the order id

{% tabs %}
{% tab title="200: OK " %}

```json
{
    "status": true,
    "data": {
        "id": 2,
        "user_id": 2388,
        "package_id": 1,
        "status": "suspended",
        "name": "Your personal server",
        "service": "universal",
        "domain": null,
        "price": {
            "id": 2,
            "package_id": 2,
            "type": "single",
            "period": 90,
            "price": 333,
            "renewal_price": 333,
            "setup_fee": 0,
            "cancellation_fee": 0,
            "data": null,
            "is_active": 1,
            "created_at": "2024-01-09T19:22:17.000000Z",
            "updated_at": "2024-01-09T19:22:26.000000Z"
        },
        "options": {
            "coupon": null
        },
        "data": {
            "test": true
        },
        "notes": null,
        "cancelled_at": null,
        "cancel_reason": null,
        "last_renewed_at": "2024-01-09T19:29:59.000000Z",
        "due_date": "2025-04-17T00:00:00.000000Z",
        "created_at": "2024-01-09T18:29:25.000000Z",
        "updated_at": "2024-01-09T19:58:35.000000Z",
        "package": {
            "id": 1,
            "order": 0,
            "category_id": 1,
            "name": "Universal",
            "description": "",
            "icon": "universal.png",
            "service": "universal",
            "status": "restricted",
            "global_quantity": -1,
            "client_quantity": -1,
            "require_domain": 0,
            "allow_coupons": 1,
            "allow_notes": 1,
            "data": null,
            "setup_on": "payment_received",
            "created_at": "2024-01-09T18:28:54.000000Z",
            "updated_at": "2024-01-09T18:29:37.000000Z",
            "emails": [],
            "webhooks": []
        }
    }
}
```

{% endtab %}
{% endtabs %}

## Unsuspend an order

<mark style="color:green;">`POST`</mark> `https://wemx.app/api/v1/orders/{order}/unsuspend`

Unsuspend a order from the order id

{% tabs %}
{% tab title="200: OK " %}

```json
{
    "status": true,
    "data": {
        "id": 2,
        "user_id": 2388,
        "package_id": 1,
        "status": "active",
        "name": "Your personal server",
        "service": "universal",
        "domain": null,
        "price": {
            "id": 2,
            "package_id": 2,
            "type": "single",
            "period": 90,
            "price": 333,
            "renewal_price": 333,
            "setup_fee": 0,
            "cancellation_fee": 0,
            "data": null,
            "is_active": 1,
            "created_at": "2024-01-09T19:22:17.000000Z",
            "updated_at": "2024-01-09T19:22:26.000000Z"
        },
        "options": {
            "coupon": null
        },
        "data": {
            "test": true
        },
        "notes": null,
        "cancelled_at": null,
        "cancel_reason": null,
        "last_renewed_at": "2024-01-09T19:29:59.000000Z",
        "due_date": "2025-04-17T00:00:00.000000Z",
        "created_at": "2024-01-09T18:29:25.000000Z",
        "updated_at": "2024-01-09T19:59:58.000000Z",
        "package": {
            "id": 1,
            "order": 0,
            "category_id": 1,
            "name": "Universal",
            "description": "",
            "icon": "universal.png",
            "service": "universal",
            "status": "restricted",
            "global_quantity": -1,
            "client_quantity": -1,
            "require_domain": 0,
            "allow_coupons": 1,
            "allow_notes": 1,
            "data": null,
            "setup_on": "payment_received",
            "created_at": "2024-01-09T18:28:54.000000Z",
            "updated_at": "2024-01-09T18:29:37.000000Z",
            "emails": [],
            "webhooks": []
        }
    }
}
```

{% endtab %}
{% endtabs %}

## Terminate an order

<mark style="color:green;">`POST`</mark> `https://wemx.app/api/v1/orders/{order}/terminate`

Terminate an order from the order id

#### Request Body

| Name  | Type    | Description                    |
| ----- | ------- | ------------------------------ |
| force | Boolean | Forcefully terminate the order |

{% tabs %}
{% tab title="200: OK " %}

```json
{
    "status": true,
    "data": {
        "id": 2,
        "user_id": 2388,
        "package_id": 1,
        "status": "terminated",
        "name": "Your personal server",
        "service": "universal",
        "domain": null,
        "price": {
            "id": 2,
            "package_id": 2,
            "type": "single",
            "period": 90,
            "price": 333,
            "renewal_price": 333,
            "setup_fee": 0,
            "cancellation_fee": 0,
            "data": null,
            "is_active": 1,
            "created_at": "2024-01-09T19:22:17.000000Z",
            "updated_at": "2024-01-09T19:22:26.000000Z"
        },
        "options": {
            "coupon": null
        },
        "data": {
            "test": true
        },
        "notes": null,
        "cancelled_at": null,
        "cancel_reason": null,
        "last_renewed_at": "2024-01-09T19:29:59.000000Z",
        "due_date": "2025-04-17T00:00:00.000000Z",
        "created_at": "2024-01-09T18:29:25.000000Z",
        "updated_at": "2024-01-09T20:01:30.000000Z",
        "package": {
            "id": 1,
            "order": 0,
            "category_id": 1,
            "name": "Universal",
            "description": "",
            "icon": "universal.png",
            "service": "universal",
            "status": "restricted",
            "global_quantity": -1,
            "client_quantity": -1,
            "require_domain": 0,
            "allow_coupons": 1,
            "allow_notes": 1,
            "data": null,
            "setup_on": "payment_received",
            "created_at": "2024-01-09T18:28:54.000000Z",
            "updated_at": "2024-01-09T18:29:37.000000Z",
            "emails": [],
            "webhooks": []
        }
    }
}
```

{% endtab %}
{% endtabs %}
