# Misc › Carbon Calculator API

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

> 6 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/misc/carbon-calculator/

OpenAPI v1: https://api.eu.ovhcloud.com/1.0/__schemas/developer-hub-navigation/misc/carbon-calculator.json?format=openapi3
OpenAPI v2: https://api.eu.ovhcloud.com/v2/__schemas/developer-hub-navigation/misc/carbon-calculator.json?format=openapi3

## Operations

- `POST /me/carbonCalculator/csv` — Create a carbon footprint csv generation task
- `GET /me/carbonCalculator/hasInvoice` — Find out if the account has data to generate invoice
- `POST /me/carbonCalculator/pdf` — Create a carbon footprint pdf generation task
- `GET /me/carbonCalculator/task` — List all tasks
- `POST /me/carbonCalculator/task` — Create a carbon footprint generation task
- `GET /me/carbonCalculator/task/{taskID}` — Fetch a task by its ID

## Create a carbon footprint csv generation task

`POST /1.0/me/carbonCalculator/csv`

Link: https://developers.eu.ovhcloud.com/reference/misc/carbon-calculator/#post-me-carboncalculator-csv

**Status:** Stable production version  
**IAM actions:** `account:apiovh:me/carbonCalculator/task/create`

### Request body (required)

Type: `carbonCalculator.CalculationCSVRequest`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `endMonth` | string (date) | yes | End month of computation. Must be after start month. Only year and month are used; the day is ignored. |
| `startMonth` | string (date) | yes | Start month of computation. Must be before end month. Only year and month are used; the day is ignored. |

```json
{
  "endMonth": "2024-01-01",
  "startMonth": "2024-01-01"
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | carbonCalculator.CalculationResponse | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `taskID` | string | read-only | ID of the calculation task |

```json
{
  "taskID": "string"
}
```

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/1.0/me/carbonCalculator/csv" \
  -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: carbonCalculator.CalculationCSVRequest
result = client.post("/me/carbonCalculator/csv",
	endMonth = None, # End month of computation. Must be after start month. Only year and month are used; the day is ignored. (type: string)
	startMonth = None, # Start month of computation. Must be before end month. Only year and month are used; the day is ignored. (type: string)
)

# 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: carbonCalculator.CalculationCSVRequest
$result = $ovh->post("/me/carbonCalculator/csv", array(
	endMonth => null, // End month of computation. Must be after start month. Only year and month are used; the day is ignored. (type: string)
	startMonth => null, // Start month of computation. Must be before end month. Only year and month are used; the day is ignored. (type: string)
));

print_r($result);
?>
```

## Find out if the account has data to generate invoice

`GET /1.0/me/carbonCalculator/hasInvoice`

Link: https://developers.eu.ovhcloud.com/reference/misc/carbon-calculator/#get-me-carboncalculator-hasinvoice

**Status:** Stable production version  
**IAM actions:** `account:apiovh:me/carbonCalculator/hasInvoice/get`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `date` | query | string (date) |  | Month of the requested invoice (day is ignored) |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | carbonCalculator.HasInvoiceResponse | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `hasInvoice` | boolean | read-only | Whether the account has data to generate invoice |

```json
{
  "hasInvoice": true
}
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/1.0/me/carbonCalculator/hasInvoice" \
  -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/carbonCalculator/hasInvoice")

# 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/carbonCalculator/hasInvoice");

print_r($result);
?>
```

## Create a carbon footprint pdf generation task

`POST /1.0/me/carbonCalculator/pdf`

Link: https://developers.eu.ovhcloud.com/reference/misc/carbon-calculator/#post-me-carboncalculator-pdf

**Status:** Stable production version  
**IAM actions:** `account:apiovh:me/carbonCalculator/task/create`

### Request body (required)

Type: `carbonCalculator.CalculationPDFRequest`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `month` | string (date) | yes | Month of computation. Must be between last month and last month - 24 months. Only year and month are used; the day is ignored |

```json
{
  "month": "2024-01-01"
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | carbonCalculator.CalculationResponse | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `taskID` | string | read-only | ID of the calculation task |

```json
{
  "taskID": "string"
}
```

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/1.0/me/carbonCalculator/pdf" \
  -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: carbonCalculator.CalculationPDFRequest
result = client.post("/me/carbonCalculator/pdf",
	month = None, # Month of computation. Must be between last month and last month - 24 months. Only year and month are used; the day is ignored (type: string)
)

# 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: carbonCalculator.CalculationPDFRequest
$result = $ovh->post("/me/carbonCalculator/pdf", array(
	month => null, // Month of computation. Must be between last month and last month - 24 months. Only year and month are used; the day is ignored (type: string)
));

print_r($result);
?>
```

## List all tasks

`GET /1.0/me/carbonCalculator/task`

Link: https://developers.eu.ovhcloud.com/reference/misc/carbon-calculator/#get-me-carboncalculator-task

**Status:** Stable production version  
**IAM actions:** `account:apiovh:me/carbonCalculator/task/get`

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | carbonCalculator.Task[] | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `link` | string | read-only | Link to the document |
| `status` | carbonCalculator.Task.TaskStatusEnum | read-only | Status of the task — one of `ERROR`, `IN_PROGRESS`, `SUCCESS` |
| `taskID` | string | read-only | ID of the task |

```json
[
  {
    "link": "string",
    "status": "ERROR",
    "taskID": "string"
  }
]
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/1.0/me/carbonCalculator/task" \
  -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/carbonCalculator/task")

# 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/carbonCalculator/task");

print_r($result);
?>
```

## Create a carbon footprint generation task

`POST /1.0/me/carbonCalculator/task`

Link: https://developers.eu.ovhcloud.com/reference/misc/carbon-calculator/#post-me-carboncalculator-task

**Status:** Stable production version  
**IAM actions:** `account:apiovh:me/carbonCalculator/task/create`

### Request body (required)

Type: `carbonCalculator.CalculationRequest`

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `date` | string (date) | yes | Month of the requested document (day is ignored) |

```json
{
  "date": "2024-01-01"
}
```

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | carbonCalculator.CalculationResponse | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `taskID` | string | read-only | ID of the calculation task |

```json
{
  "taskID": "string"
}
```

### Example

```bash
curl -X POST \
  "https://api.eu.ovhcloud.com/1.0/me/carbonCalculator/task" \
  -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: carbonCalculator.CalculationRequest
result = client.post("/me/carbonCalculator/task",
	date = None, # Month of the requested document (day is ignored) (type: string)
)

# 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: carbonCalculator.CalculationRequest
$result = $ovh->post("/me/carbonCalculator/task", array(
	date => null, // Month of the requested document (day is ignored) (type: string)
));

print_r($result);
?>
```

## Fetch a task by its ID

`GET /1.0/me/carbonCalculator/task/{taskID}`

Link: https://developers.eu.ovhcloud.com/reference/misc/carbon-calculator/#get-me-carboncalculator-task-taskid

**Status:** Stable production version  
**IAM actions:** `account:apiovh:me/carbonCalculator/task/get`

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `taskID` | path | string | yes | TaskID |

### Responses

| Status | Type | Description |
| --- | --- | --- |
| 200 | carbonCalculator.Task | successful operation |

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `link` | string | read-only | Link to the document |
| `status` | carbonCalculator.Task.TaskStatusEnum | read-only | Status of the task — one of `ERROR`, `IN_PROGRESS`, `SUCCESS` |
| `taskID` | string | read-only | ID of the task |

```json
{
  "link": "string",
  "status": "ERROR",
  "taskID": "string"
}
```

### Example

```bash
curl -X GET \
  "https://api.eu.ovhcloud.com/1.0/me/carbonCalculator/task/{taskID}" \
  -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/carbonCalculator/task/{taskID}")

# 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/carbonCalculator/task/{taskID}");

print_r($result);
?>
```
