# Orders

Order management

## Fetch a list of Orders

`GET /orders`

Without params, it returns a list of Orders the user has access to

Authentication (security requirement alternatives):

```json
[
  {
    "BasicAuth": []
  },
  {
    "ApiKey": []
  }
]
```

- BasicAuth: http (basic)
- ApiKey: http (bearer)

Parameters:

- `all` (query, boolean, optional) - Can only be used by admins or managers to fetch all entities
  Type: boolean

- `userId` (query, integer, optional) - Standard users can use this only with their own _userId_
  Type: integer

- `excludeAttributes` (query, boolean, optional) - Skip returning the attributes map
  Type: boolean

- `limit` (query, integer, optional) - Limit the number of returned results
  Type: integer

- `offset` (query, integer, optional) - Offset for pagination
  Type: integer

- `keyword` (query, string, optional) - Search keyword filter
  Type: string

Responses:

- 200: OK

Content type: application/json

Type: Array<Order>

Items:
  Reference: [Order](https://sourcey-traccar.pages.dev/api-reference/models/order/index.md); Type: Order

- 401: Unauthorized

## Examples

### cURL

```bash
curl -X GET 'https://demo.traccar.org/api/orders' \
  -H 'Authorization: Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE'
```

### JavaScript

```javascript
const response = await fetch('https://demo.traccar.org/api/orders', {
  method: 'GET',
  headers: {
    'Authorization': 'Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE',
  },
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.get(
    'https://demo.traccar.org/api/orders',
    headers={
        'Authorization': 'Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE',
    },
)
print(response.text)
```


## Create an Order

`POST /orders`

Authentication (security requirement alternatives):

```json
[
  {
    "BasicAuth": []
  },
  {
    "ApiKey": []
  }
]
```

- BasicAuth: http (basic)
- ApiKey: http (bearer)

Request body: application/json (required)

Type: Order

Schema: [Order](https://sourcey-traccar.pages.dev/api-reference/models/order/index.md)

- `id` (optional)
  Type: integer, int64
  
  Unique order identifier

- `uniqueId` (optional)
  Type: string
  
  External order identifier used by clients

- `description` (optional)
  Type: string
  
  Additional details about the order assignment

- `fromAddress` (optional)
  Type: string
  
  Pickup location address

- `toAddress` (optional)
  Type: string
  
  Destination address

- `attributes` (optional)
  Type: object
  
  Custom order attributes

Responses:

- 200: OK

Content type: application/json

Type: Order

Schema: [Order](https://sourcey-traccar.pages.dev/api-reference/models/order/index.md)

- `id` (optional)
  Type: integer, int64
  
  Unique order identifier

- `uniqueId` (optional)
  Type: string
  
  External order identifier used by clients

- `description` (optional)
  Type: string
  
  Additional details about the order assignment

- `fromAddress` (optional)
  Type: string
  
  Pickup location address

- `toAddress` (optional)
  Type: string
  
  Destination address

- `attributes` (optional)
  Type: object
  
  Custom order attributes

- 400: Bad request

- 401: Unauthorized

## Examples

### cURL

```bash
curl -X POST 'https://demo.traccar.org/api/orders' \
  -H 'Authorization: Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "id": 0,
  "uniqueId": "string",
  "description": "string",
  "fromAddress": "string",
  "toAddress": "string",
  "attributes": {}
}'
```

### JavaScript

```javascript
const body = `{
  "id": 0,
  "uniqueId": "string",
  "description": "string",
  "fromAddress": "string",
  "toAddress": "string",
  "attributes": {}
}`;

const response = await fetch('https://demo.traccar.org/api/orders', {
  method: 'POST',
  headers: {
    'Authorization': 'Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE',
    'Content-Type': 'application/json',
  },
  body,
});

const data = await response.text();
```

### Python

```python
import requests

body = '''{
  "id": 0,
  "uniqueId": "string",
  "description": "string",
  "fromAddress": "string",
  "toAddress": "string",
  "attributes": {}
}'''

response = requests.post(
    'https://demo.traccar.org/api/orders',
    data=body.encode('utf-8'),
    headers={
        'Authorization': 'Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE',
        'Content-Type': 'application/json',
    },
)
print(response.text)
```


## Fetch an Order

`GET /orders/{id}`

Authentication (security requirement alternatives):

```json
[
  {
    "BasicAuth": []
  },
  {
    "ApiKey": []
  }
]
```

- BasicAuth: http (basic)
- ApiKey: http (bearer)

Parameters:

- `id` (path, integer, required)
  Type: integer

Responses:

- 200: OK

Content type: application/json

Type: Order

Schema: [Order](https://sourcey-traccar.pages.dev/api-reference/models/order/index.md)

- `id` (optional)
  Type: integer, int64
  
  Unique order identifier

- `uniqueId` (optional)
  Type: string
  
  External order identifier used by clients

- `description` (optional)
  Type: string
  
  Additional details about the order assignment

- `fromAddress` (optional)
  Type: string
  
  Pickup location address

- `toAddress` (optional)
  Type: string
  
  Destination address

- `attributes` (optional)
  Type: object
  
  Custom order attributes

- 401: Unauthorized

- 404: Not found

## Examples

### cURL

```bash
curl -X GET 'https://demo.traccar.org/api/orders/0' \
  -H 'Authorization: Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE'
```

### JavaScript

```javascript
const response = await fetch('https://demo.traccar.org/api/orders/0', {
  method: 'GET',
  headers: {
    'Authorization': 'Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE',
  },
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.get(
    'https://demo.traccar.org/api/orders/0',
    headers={
        'Authorization': 'Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE',
    },
)
print(response.text)
```


## Update an Order

`PUT /orders/{id}`

Authentication (security requirement alternatives):

```json
[
  {
    "BasicAuth": []
  },
  {
    "ApiKey": []
  }
]
```

- BasicAuth: http (basic)
- ApiKey: http (bearer)

Parameters:

- `id` (path, integer, required)
  Type: integer

Request body: application/json (required)

Type: Order

Schema: [Order](https://sourcey-traccar.pages.dev/api-reference/models/order/index.md)

- `id` (optional)
  Type: integer, int64
  
  Unique order identifier

- `uniqueId` (optional)
  Type: string
  
  External order identifier used by clients

- `description` (optional)
  Type: string
  
  Additional details about the order assignment

- `fromAddress` (optional)
  Type: string
  
  Pickup location address

- `toAddress` (optional)
  Type: string
  
  Destination address

- `attributes` (optional)
  Type: object
  
  Custom order attributes

Responses:

- 200: OK

Content type: application/json

Type: Order

Schema: [Order](https://sourcey-traccar.pages.dev/api-reference/models/order/index.md)

- `id` (optional)
  Type: integer, int64
  
  Unique order identifier

- `uniqueId` (optional)
  Type: string
  
  External order identifier used by clients

- `description` (optional)
  Type: string
  
  Additional details about the order assignment

- `fromAddress` (optional)
  Type: string
  
  Pickup location address

- `toAddress` (optional)
  Type: string
  
  Destination address

- `attributes` (optional)
  Type: object
  
  Custom order attributes

- 400: Bad request

- 401: Unauthorized

## Examples

### cURL

```bash
curl -X PUT 'https://demo.traccar.org/api/orders/0' \
  -H 'Authorization: Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "id": 0,
  "uniqueId": "string",
  "description": "string",
  "fromAddress": "string",
  "toAddress": "string",
  "attributes": {}
}'
```

### JavaScript

```javascript
const body = `{
  "id": 0,
  "uniqueId": "string",
  "description": "string",
  "fromAddress": "string",
  "toAddress": "string",
  "attributes": {}
}`;

const response = await fetch('https://demo.traccar.org/api/orders/0', {
  method: 'PUT',
  headers: {
    'Authorization': 'Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE',
    'Content-Type': 'application/json',
  },
  body,
});

const data = await response.text();
```

### Python

```python
import requests

body = '''{
  "id": 0,
  "uniqueId": "string",
  "description": "string",
  "fromAddress": "string",
  "toAddress": "string",
  "attributes": {}
}'''

response = requests.put(
    'https://demo.traccar.org/api/orders/0',
    data=body.encode('utf-8'),
    headers={
        'Authorization': 'Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE',
        'Content-Type': 'application/json',
    },
)
print(response.text)
```


## Delete an Order

`DELETE /orders/{id}`

Authentication (security requirement alternatives):

```json
[
  {
    "BasicAuth": []
  },
  {
    "ApiKey": []
  }
]
```

- BasicAuth: http (basic)
- ApiKey: http (bearer)

Parameters:

- `id` (path, integer, required)
  Type: integer

Responses:

- 204: No Content

- 401: Unauthorized

## Examples

### cURL

```bash
curl -X DELETE 'https://demo.traccar.org/api/orders/0' \
  -H 'Authorization: Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE'
```

### JavaScript

```javascript
const response = await fetch('https://demo.traccar.org/api/orders/0', {
  method: 'DELETE',
  headers: {
    'Authorization': 'Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE',
  },
});

const data = await response.text();
```

### Python

```python
import requests

response = requests.delete(
    'https://demo.traccar.org/api/orders/0',
    headers={
        'Authorization': 'Basic WU9VUl9VU0VSTkFNRTpZT1VSX1BBU1NXT1JE',
    },
)
print(response.text)
```
