# Offers & Services › Purchase Orders API

> Part of the OVHcloud developer hub. Index of every page and section: https://developers.eu.ovhcloud.com/llms.txt
> The Offers & Services product's sections: https://developers.eu.ovhcloud.com/reference/offers-services/llms.txt
> Everything in one file: https://developers.eu.ovhcloud.com/llms-full.txt

> 5 operations of the OVHcloud API. Calls carry `authorization: Bearer $OVH_TOKEN`; the EU host is shown, Canada and the United States answer on api.ca.ovhcloud.com and api.us.ovhcloud.com.

Page: https://developers.eu.ovhcloud.com/reference/offers-services/purchase-orders/

OpenAPI v1: https://api.eu.ovhcloud.com/1.0/__schemas/developer-hub-navigation/offers-services/purchase-orders.json?format=openapi3
OpenAPI v2: https://api.eu.ovhcloud.com/v2/__schemas/developer-hub-navigation/offers-services/purchase-orders.json?format=openapi3

## Operations

- `GET /me/billing/purchaseOrder` — Retrieve all purchase orders
- `POST /me/billing/purchaseOrder` — Create a purchase order
- `GET /me/billing/purchaseOrder/{id}` — Retrieve information about a purchase order
- `PUT /me/billing/purchaseOrder/{id}` — Update a purchase order
- `DELETE /me/billing/purchaseOrder/{id}` — Delete a purchase order

## Retrieve all purchase orders

`GET /1.0/me/billing/purchaseOrder`

Link: https://developers.eu.ovhcloud.com/reference/offers-services/purchase-orders/#get-me-billing-purchaseorder

**Status:** Beta version  
**IAM actions:** `account:apiovh:me/billing/purchaseOrder/get`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `billingGroupId` | query | integer |  | Billing Group Identifier |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | integer[] | successful operation |

```json
[
  0
]
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/1.0/me/billing/purchaseOrder" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/me/billing/purchaseOrder")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/me/billing/purchaseOrder");

print_r($result);
?>
```

## Create a purchase order

`POST /1.0/me/billing/purchaseOrder`

Link: https://developers.eu.ovhcloud.com/reference/offers-services/purchase-orders/#post-me-billing-purchaseorder

**Status:** Beta version  
**IAM actions:** `account:apiovh:me/billing/purchaseOrder/create`

### Request body (required)

Type: `me.billing.purchaseOrder.Creation`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `active` | boolean |  | Active |
| `billingGroupId` | integer |  | Billing Group identifier |
| `description` | string |  | Description |
| `endDate` | string (date) |  | End date |
| `reference` | string | yes | Reference |
| `startDate` | string (date) | yes | Start date |
| `type` | me.billing.purchaseOrder.PurchaseOrderTypeEnum | yes | Type of a purchase order — one of `PURCHASE_ORDER`, `REFERENCE_ORDER` |

```json
{
  "active": true,
  "billingGroupId": 0,
  "description": "string",
  "endDate": "2024-01-01",
  "reference": "string",
  "startDate": "2024-01-01",
  "type": "PURCHASE_ORDER"
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | me.billing.purchaseOrder.PurchaseOrder | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `active` | boolean | read-only | Active |
| `billingGroupId` | integer | read-only | Billing Group identifier |
| `creationDate` | string (date-time) | read-only | Creation date |
| `description` | string | read-only | Description |
| `endDate` | string (date) | read-only | End date |
| `id` | integer | read-only | Purchase Order identifier |
| `lastUpdate` | string (date-time) | read-only | Last update date |
| `reference` | string | read-only | Reference |
| `startDate` | string (date) | read-only | Start date |
| `status` | me.billing.purchaseOrder.StatusEnum | read-only | Status — one of `CREATED`, `DELETED` |
| `type` | me.billing.purchaseOrder.PurchaseOrderTypeEnum | read-only | Type of a purchase order — one of `PURCHASE_ORDER`, `REFERENCE_ORDER` |

```json
{
  "active": true,
  "billingGroupId": 0,
  "creationDate": "2024-01-01T12:00:00Z",
  "description": "string",
  "endDate": "2024-01-01",
  "id": 0,
  "lastUpdate": "2024-01-01T12:00:00Z",
  "reference": "string",
  "startDate": "2024-01-01",
  "status": "CREATED",
  "type": "PURCHASE_ORDER"
}
```

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/1.0/me/billing/purchaseOrder" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN" \
  -H "content-type: application/json" \
  -d '{ }'
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

# Request body type: me.billing.purchaseOrder.Creation
result = client.post("/me/billing/purchaseOrder",
	active = None, # Active (type: boolean, nullable)
	billingGroupId = None, # Billing Group identifier (type: integer, nullable)
	description = None, # Description (type: string, nullable)
	endDate = None, # End date (type: string, nullable)
	reference = None, # Reference (type: string)
	startDate = None, # Start date (type: string)
	type = None, # Type of a purchase order (type: me.billing.purchaseOrder.PurchaseOrderTypeEnum)
)

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

// Request body type: me.billing.purchaseOrder.Creation
$result = $ovh->post("/me/billing/purchaseOrder", array(
	active => null, // Active (type: boolean, nullable)
	billingGroupId => null, // Billing Group identifier (type: integer, nullable)
	description => null, // Description (type: string, nullable)
	endDate => null, // End date (type: string, nullable)
	reference => null, // Reference (type: string)
	startDate => null, // Start date (type: string)
	type => null, // Type of a purchase order (type: me.billing.purchaseOrder.PurchaseOrderTypeEnum)
));

print_r($result);
?>
```

## Retrieve information about a purchase order

`GET /1.0/me/billing/purchaseOrder/{id}`

Link: https://developers.eu.ovhcloud.com/reference/offers-services/purchase-orders/#get-me-billing-purchaseorder-id

**Status:** Beta version  
**IAM actions:** `account:apiovh:me/billing/purchaseOrder/get`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | integer | yes | Id |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | me.billing.purchaseOrder.PurchaseOrder | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `active` | boolean | read-only | Active |
| `billingGroupId` | integer | read-only | Billing Group identifier |
| `creationDate` | string (date-time) | read-only | Creation date |
| `description` | string | read-only | Description |
| `endDate` | string (date) | read-only | End date |
| `id` | integer | read-only | Purchase Order identifier |
| `lastUpdate` | string (date-time) | read-only | Last update date |
| `reference` | string | read-only | Reference |
| `startDate` | string (date) | read-only | Start date |
| `status` | me.billing.purchaseOrder.StatusEnum | read-only | Status — one of `CREATED`, `DELETED` |
| `type` | me.billing.purchaseOrder.PurchaseOrderTypeEnum | read-only | Type of a purchase order — one of `PURCHASE_ORDER`, `REFERENCE_ORDER` |

```json
{
  "active": true,
  "billingGroupId": 0,
  "creationDate": "2024-01-01T12:00:00Z",
  "description": "string",
  "endDate": "2024-01-01",
  "id": 0,
  "lastUpdate": "2024-01-01T12:00:00Z",
  "reference": "string",
  "startDate": "2024-01-01",
  "status": "CREATED",
  "type": "PURCHASE_ORDER"
}
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/1.0/me/billing/purchaseOrder/{id}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.get("/me/billing/purchaseOrder/{id}")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->get("/me/billing/purchaseOrder/{id}");

print_r($result);
?>
```

## Update a purchase order

`PUT /1.0/me/billing/purchaseOrder/{id}`

Link: https://developers.eu.ovhcloud.com/reference/offers-services/purchase-orders/#put-me-billing-purchaseorder-id

**Status:** Beta version  
**IAM actions:** `account:apiovh:me/billing/purchaseOrder/edit`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | integer | yes | Id |

### Request body (required)

Type: `me.billing.purchaseOrder.Update`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `active` | boolean |  | Active |
| `billingGroupId` | integer |  | Billing group identifier |
| `description` | string |  | Description |
| `endDate` | string (date) |  | End date |
| `reference` | string |  | Reference |
| `startDate` | string (date) |  | Start date |
| `type` | me.billing.purchaseOrder.PurchaseOrderTypeEnum |  | Type of a purchase order — one of `PURCHASE_ORDER`, `REFERENCE_ORDER` |

```json
{
  "active": true,
  "billingGroupId": 0,
  "description": "string",
  "endDate": "2024-01-01",
  "reference": "string",
  "startDate": "2024-01-01",
  "type": "PURCHASE_ORDER"
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | — | successful operation |

### Example

```bash
curl -X PUT \
  "https://api.eu.ovhcloud.com/1.0/me/billing/purchaseOrder/{id}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN" \
  -H "content-type: application/json" \
  -d '{ }'
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

# Request body type: me.billing.purchaseOrder.Update
result = client.put("/me/billing/purchaseOrder/{id}",
	active = None, # Active (type: boolean, nullable)
	billingGroupId = None, # Billing group identifier (type: integer, nullable)
	description = None, # Description (type: string, nullable)
	endDate = None, # End date (type: string, nullable)
	reference = None, # Reference (type: string, nullable)
	startDate = None, # Start date (type: string, nullable)
	type = None, # Type of a purchase order (type: me.billing.purchaseOrder.PurchaseOrderTypeEnum, nullable)
)

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

// Request body type: me.billing.purchaseOrder.Update
$result = $ovh->put("/me/billing/purchaseOrder/{id}", array(
	active => null, // Active (type: boolean, nullable)
	billingGroupId => null, // Billing group identifier (type: integer, nullable)
	description => null, // Description (type: string, nullable)
	endDate => null, // End date (type: string, nullable)
	reference => null, // Reference (type: string, nullable)
	startDate => null, // Start date (type: string, nullable)
	type => null, // Type of a purchase order (type: me.billing.purchaseOrder.PurchaseOrderTypeEnum, nullable)
));

print_r($result);
?>
```

## Delete a purchase order

`DELETE /1.0/me/billing/purchaseOrder/{id}`

Link: https://developers.eu.ovhcloud.com/reference/offers-services/purchase-orders/#delete-me-billing-purchaseorder-id

**Status:** Beta version  
**IAM actions:** `account:apiovh:me/billing/purchaseOrder/delete`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | path | integer | yes | Id |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | — | successful operation |

### Example

```bash
curl -X DELETE \
  "https://api.eu.ovhcloud.com/1.0/me/billing/purchaseOrder/{id}" \
  -H "accept: application/json" \
  -H "authorization: Bearer $OVH_TOKEN"
```

```python
'''
First, install the latest release of Python wrapper: $ pip install ovh
'''
import json
import ovh

# Instantiate an OVH Client.
# You can generate new credentials with full access to your account on
# the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
client = ovh.Client(
	endpoint='ovh-eu',               # Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
	application_key='xxxxxxxxxx',    # Application Key
	application_secret='xxxxxxxxxx', # Application Secret
	consumer_key='xxxxxxxxxx',       # Consumer Key
)

result = client.delete("/me/billing/purchaseOrder/{id}")

# Pretty print
print(json.dumps(result, indent=4))
```

```php
<?php
/**
 * First, download the latest release of PHP wrapper on github
 * And include this script into the folder with extracted files
 */
require __DIR__ . '/vendor/autoload.php';
use \Ovh\Api;

/**
 * Instantiate an OVH Client.
 * You can generate new credentials with full access to your account on
 * the token creation page (https://api.ovh.com/createToken/index.cgi?GET=/*&PUT=/*&POST=/*&DELETE=/*)
 */
$ovh = new Api('xxxxxxxxxx',  // Application Key
               'xxxxxxxxxx',  // Application Secret
               'ovh-eu',      // Endpoint of API OVH (List of available endpoints: https://github.com/ovh/python-ovh#2-configure-your-application)
               'xxxxxxxxxx'); // Consumer Key

$result = $ovh->delete("/me/billing/purchaseOrder/{id}");

print_r($result);
?>
```
