> ## Documentation Index
> Fetch the complete documentation index at: https://docs.m3ter.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Statementjobs

## Get StatementJob

**Function name:** `m3ter_GetStatementJob`
**Category:** READ
**HTTP method:** GET
**Destination:** m3ter

Retrieves the details of a specific StatementJob using its UUID.

Use this call to obtain the time-bound pre-signed download URL for the generated Bill Statement if the initial [Create StatementJob](https://www.m3ter.com/docs/api#tag/StatementJob/operation/CreateStatementJob) returned a response showing the `statementJobStatus` not yet complete and as `PENDING` or `RUNNING`.

**Note:** When you have submitted a StatementJob and a Bill Statement has been generated, you can also download the Statement directly from a Bill Details page in the Console. See [Working with Bill Statements](https://www.m3ter.com/docs/guides/billing-and-usage-data/running-viewing-and-managing-bills/working-with-bill-statements) in our user Documentation.

### Parameters

| Name                       | Label       | Type                   | Required | Description                           | Constraints                                                           |
| -------------------------- | ----------- | ---------------------- | :------: | ------------------------------------- | --------------------------------------------------------------------- |
| `integrationCredentialsId` | Credentials | M3terEntityParameter   |    Yes   | The m3ter credentials to use.         | m3terEntity: IntegrationCredentials, authType: M3TER\_SIGNED\_REQUEST |
| `id`                       | id          | LookupParameter        |    Yes   |                                       | -                                                                     |
| `statePath`                | State Path  | StateVariableParameter |    No    | State variable to store the response. | -                                                                     |

### Exits

| Exit    | Description                                                                      |
| ------- | -------------------------------------------------------------------------------- |
| `NEXT`  | The API call succeeded.                                                          |
| `ERROR` | The API call failed. Error details are stored in the `m3shError` state variable. |

## List Statement Jobs

**Function name:** `m3ter_ListStatementJobs`
**Category:** READ
**HTTP method:** GET (paginated)
**Destination:** m3ter

Retrieve a list of StatementJobs.

Retrieves a list of all StatementJobs for a specific Organization. You can filter the results based on:

* StatementJob status.
* Whether StatementJob is neither completed nor cancelled but remains active.
* The ID of the Bill the StatementJob is associated with.

You can also paginate the results for easier management.

**WARNING!**

* You can use only one of the valid Query parameters: `active`, `status`, or `billId` in any call. If you use more than one of these Query parameters in the same call, then a 400 Bad Request is returned with an error message.

### Parameters

| Name                       | Label            | Type                    | Required | Description                                | Constraints                                                           |
| -------------------------- | ---------------- | ----------------------- | :------: | ------------------------------------------ | --------------------------------------------------------------------- |
| `integrationCredentialsId` | Credentials      | M3terEntityParameter    |    Yes   | The m3ter credentials to use.              | m3terEntity: IntegrationCredentials, authType: M3TER\_SIGNED\_REQUEST |
| `statePath`                | State Path       | StateVariableParameter  |    No    | State variable to store the response.      | -                                                                     |
| `queryParams`              | Query Parameters | KeyValueLookupParameter |    No    | Query parameters to include in the request | allowedValues: active,status,billId                                   |

### Exits

| Exit    | Description                                                                      |
| ------- | -------------------------------------------------------------------------------- |
| `NEXT`  | The API call succeeded.                                                          |
| `ERROR` | The API call failed. Error details are stored in the `m3shError` state variable. |

## Create StatementJob

**Function name:** `m3ter_CreateStatementJob`
**Category:** WRITE
**HTTP method:** POST
**Destination:** m3ter

This endpoint creates a StatementJob for a single bill within an Organization using the Bill UUID.

The Bill Statement is generated asynchronously:

* The default format for generating the Statement is in JSON format and according to the Bill Statement Definition you've specified at either Organization level or Account level.
* If you also want to generate the Statement in CSV format, use the `includeCsvFormat` request body parameter.
* The response body provides a time-bound pre-signed URL, which you can use to download the JSON format Statement.
* When you have generated a Statement for a Bill, you can also obtain a time-bound pre-signed download URL using either the [Retrieve Bill Statement in JSON Format](https://www.m3ter.com/docs/api#tag/Bill/operation/GetBillJsonStatement) and [Retrieve Bill Statement in CSV Format](https://www.m3ter.com/docs/api#tag/Bill/operation/GetBillCsvStatement) calls found in the [Bill](https://www.m3ter.com/docs/api#tag/Bill) section of this API Reference.

**Notes:**

* If the response to the Create StatementJob call shows the `statementJobStatus` as `PENDING` or `RUNNING`, you will not receive the pre-signed URL in the response. Wait a few minutes to allow the StatementJob to complete and then use the [Get StatmentJob](https://www.m3ter.com/docs/api#tag/StatementJob/operation/GetStatementJob) call in this section to obtain the pre-signed download URL for the generated Bill Statement.
* When you have submitted a StatementJob and a Bill Statement has been generated, you can also download the Statement directly from a Bill Details page in the Console. See [Working with Bill Statements](https://www.m3ter.com/docs/guides/billing-and-usage-data/running-viewing-and-managing-bills/working-with-bill-statements) in our user Documentation.

### Parameters

| Name                       | Label        | Type                   | Required | Description                            | Constraints                                                           |
| -------------------------- | ------------ | ---------------------- | :------: | -------------------------------------- | --------------------------------------------------------------------- |
| `integrationCredentialsId` | Credentials  | M3terEntityParameter   |    Yes   | The m3ter credentials to use.          | m3terEntity: IntegrationCredentials, authType: M3TER\_SIGNED\_REQUEST |
| `requestPath`              | Request Path | StateVariableParameter |    Yes   | State variable containing the request. | -                                                                     |
| `statePath`                | State Path   | StateVariableParameter |    No    | State variable to store the response.  | -                                                                     |

### Exits

| Exit    | Description                                                                      |
| ------- | -------------------------------------------------------------------------------- |
| `NEXT`  | The API call succeeded.                                                          |
| `ERROR` | The API call failed. Error details are stored in the `m3shError` state variable. |

## Create Batch StatementJobs

**Function name:** `m3ter_CreateStatementJobBatch`
**Category:** WRITE
**HTTP method:** POST
**Destination:** m3ter

Create a batch of StatementJobs for multiple bills.

Initiate the creation of multiple StatementJobs asynchronously for the list of bills with the given UUIDs:

* The default format for generating Bill Statements is in JSON format and according to the Bill Statement Definition you've specified at either Organization level or Account level.
* If you also want to generate the Statements in CSV format, use the `includeCsvFormat` request body parameter.
* The response body provides a time-bound pre-signed URL, which you can use to download the JSON format Statement.
* When you have generated a Statement for a Bill, you can also obtain a time-bound pre-signed download URL using either the [Retrieve Bill Statement in JSON Format](https://www.m3ter.com/docs/api#tag/Bill/operation/GetBillJsonStatement) and [Retrieve Bill Statement in CSV Format](https://www.m3ter.com/docs/api#tag/Bill/operation/GetBillCsvStatement) calls found in the [Bill](https://www.m3ter.com/docs/api#tag/Bill) section of this API Reference.

**Notes:**

* If the response to the Create StatementJob call shows the `statementJobStatus` as `PENDING` or `RUNNING`, you will not receive the pre-signed URL in the response. Wait a few minutes to allow the StatementJob to complete and then use the [Get StatmentJob](https://www.m3ter.com/docs/api#tag/StatementJob/operation/GetStatementJob) call in this section to obtain the pre-signed download URL for the generated Bill Statement.
* When you have submitted a StatementJob and a Bill Statement has been generated, you can also download the Statement directly from a Bill Details page in the Console. See [Working with Bill Statements](https://www.m3ter.com/docs/guides/billing-and-usage-data/running-viewing-and-managing-bills/working-with-bill-statements) in our user Documentation.

### Parameters

| Name                       | Label        | Type                   | Required | Description                            | Constraints                                                           |
| -------------------------- | ------------ | ---------------------- | :------: | -------------------------------------- | --------------------------------------------------------------------- |
| `integrationCredentialsId` | Credentials  | M3terEntityParameter   |    Yes   | The m3ter credentials to use.          | m3terEntity: IntegrationCredentials, authType: M3TER\_SIGNED\_REQUEST |
| `requestPath`              | Request Path | StateVariableParameter |    Yes   | State variable containing the request. | -                                                                     |
| `statePath`                | State Path   | StateVariableParameter |    No    | State variable to store the response.  | -                                                                     |

### Exits

| Exit    | Description                                                                      |
| ------- | -------------------------------------------------------------------------------- |
| `NEXT`  | The API call succeeded.                                                          |
| `ERROR` | The API call failed. Error details are stored in the `m3shError` state variable. |

## Cancel StatementJob

**Function name:** `m3ter_CancelStatementJob`
**Category:** WRITE
**HTTP method:** POST
**Destination:** m3ter

Cancel the StatementJob with the given UUID.

Use this endpoint to halt the execution of a specific StatementJob identified by its UUID. This operation may be useful if you need to stop a StatementJob due to unforeseen issues or changes.

### Parameters

| Name                       | Label       | Type                   | Required | Description                                                 | Constraints                                                           |
| -------------------------- | ----------- | ---------------------- | :------: | ----------------------------------------------------------- | --------------------------------------------------------------------- |
| `integrationCredentialsId` | Credentials | M3terEntityParameter   |    Yes   | The m3ter credentials to use.                               | m3terEntity: IntegrationCredentials, authType: M3TER\_SIGNED\_REQUEST |
| `id`                       | id          | LookupParameter        |    Yes   | The unique identifier (UUID) of the StatementJob to cancel. | -                                                                     |
| `statePath`                | State Path  | StateVariableParameter |    No    | State variable to store the response.                       | -                                                                     |

### Exits

| Exit    | Description                                                                      |
| ------- | -------------------------------------------------------------------------------- |
| `NEXT`  | The API call succeeded.                                                          |
| `ERROR` | The API call failed. Error details are stored in the `m3shError` state variable. |
