> This page is for Developers.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://zuora.ferndocs.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://zuora.ferndocs.com/_mcp/server.

# Run a specific version of a meter

POST https://rest.test.zuora.com/meters/run/{meterId}/{version}
Content-Type: application/json

Executes a specific version of a meter in Zuora Mediation. You can choose to run it with either a local file or event store source by providing optional configurations.

**Note on long-running meters and timeouts:** 
For large meters with many operators, this API call might take longer to return and, in some cases, can time out even though the meter run has been successfully triggered.
To safely handle this, provide a `uniqueKey` field in the request body.
If the operation times out, retry the same request with the same `uniqueKey`.
If the original run already exists, the API returns a 400 error indicating a duplicate `uniqueKey` instead of creating a new run. 


Reference: https://zuora.ferndocs.com/developers/api-reference/zuora-api/mediation/meters/run-specific-version-of-meter

## Authentication

- `Authorization` header (bearer token, required) — Use `Bearer {{token}}` in the `Authorization` header for authentication.

## Servers

- `https://rest.test.zuora.com` (US Developer & Central Sandbox (incl. Test Drive), default)
- `https://rest.sandbox.na.zuora.com` (US API Sandbox Cloud 1)
- `https://rest.apisandbox.zuora.com` (US API Sandbox Cloud 2)
- `https://rest.na.zuora.com` (US Production Cloud 1)
- `https://rest.zuora.com` (US Production Cloud 2)
- `https://rest.test.eu.zuora.com` (EU Developer & Central Sandbox)
- `https://rest.sandbox.eu.zuora.com` (EU API Sandbox)
- `https://rest.eu.zuora.com` (EU Production)
- `https://rest.test.ap.zuora.com` (APAC Developer & Central Sandbox)
- `https://rest.ap.zuora.com` (APAC Production)

## Request

### Path parameters

- `meterId` (string, required) — The ID of the meter to run. You can find this ID in the Zuora Mediation UI URL when viewing a meter.
- `version` (enum, required) — The version of the meter to run. Currently, the only supported value is `0.0.1` for all meters. Always pass `0.0.1` in this path parameter.
  - Allowed values: `0.0.1`

### Headers

- `Accept-Encoding` (string, optional) — Include the `Accept-Encoding: gzip` header to compress responses as a gzipped file. It can significantly reduce the bandwidth required for a response. If specified, Zuora automatically compresses responses that contain over 1000 bytes of data, and the response contains a `Content-Encoding` header with the compression algorithm so that your client can decompress it.
- `Content-Encoding` (string, optional) — Include the `Content-Encoding: gzip` header to compress a request. With this header specified, you should upload a gzipped file for the request payload instead of sending the JSON payload.
- `Zuora-Entity-Ids` (string, optional) — An entity ID. If you have [Zuora Multi-entity](https://knowledgecenter.zuora.com/BB_Introducing_Z_Business/Multi-entity) enabled and the OAuth token is valid for more than one entity, you must use this header to specify which entity to perform the operation in. If the OAuth token is only valid for a single entity, or you do not have Zuora Multi-entity enabled, you should not set this header.
- `Zuora-Org-Ids` (string, optional) — Comma separated IDs. If you have Zuora Multi-Org enabled, you can use this header to specify which orgs to perform the operation in. If you do not have Zuora Multi-Org enabled, you should not set this header. The IDs must be a sub-set of the user's accessible orgs. If you specify an org that the user does not have access to, the operation fails. This header is important in Multi-Org (MO) setups because it defines the organization context under which the API should operate—mainly used for read access or data visibility filtering. If the header is not set, the operation is performed in scope of the user's accessible orgs.
- `Zuora-Track-Id` (string, optional) — A custom identifier for tracing the API call. If you set a value for this header, Zuora returns the same value in the response headers. This header enables you to associate your system process identifiers with Zuora API calls, to assist with troubleshooting in the event of an issue. The value of this field must use the US-ASCII character set and must not include any of the following characters: colon (`:`), semicolon (`;`), double quote (`"`), and quote (`'`).

### Body (application/json)

This endpoint expects a RunMeterVersionRequest.

- `sourceOptions` (list of RunMeterVersionRequestSourceOptionsItems, optional) — Settings for meter to run with local file.
- `eventStoreSourceOptions` (list of RunMeterVersionRequestEventStoreSourceOptionsItems, optional) — Settings for meter to run with event store.
- `runtimeSourceConfigs` (list of RuntimeSourceConfig, optional) — Runtime source configurations to override source settings at execution time. Applies to both NORMAL and DEBUG runs.
- `uniqueKey` (string, optional) — Optional idempotency key for this meter run. The `uniqueKey` is scoped to the meter (not tenant-wide). When you trigger a meter run and the operation times out, you can safely retry the same request using the same `uniqueKey`. If the original request already created a run, Zuora Mediation returns a 400 error indicating a duplicate `uniqueKey` and does not start a new run. This behavior ensures idempotency and prevents duplicate meter executions.

## Response

### 200

Successful meter run

- `success` (boolean, optional) — Whether the API request has succeeded.
- `data` (RunMeterVersionResponseData, optional)
- `previousPage` (string, optional) — Cursor or URL for the previous page of audit records, if available. Used for backward pagination.
- `nextPage` (string, optional) — Cursor or URL for the next page of audit records, if available. Used for forward pagination.
- `error` (Error, optional) — Container for error information returned by the API when the request fails.

## Errors

### 400 Bad Request Error

Bad request

- `errors` (list of ProxyBadRequestResponseErrorsItems, optional)
- `success` (boolean, optional)

### 401 Unauthorized Error

Unauthorized request

- `errors` (list of ProxyBadRequestResponseErrorsItems, optional)
- `success` (boolean, optional)

### 500 Internal Server Error

Internal server error

- `reasons` (list of ErrorResponseReasonsItems, optional)

## Types

### RunMeterVersionRequestSourceOptionsItems

- `processorId` (string, optional) — Source operator ID. Optional if there's only one local file source in the meter.
- `localFileId` (string, optional) — Internal ID of uploaded file.

### RunMeterVersionRequestEventStoreSourceOptionsItems

- `processorId` (string, required) — Source operator ID.
- `startDate` (date, optional) — Start date of event store to query from (e.g., 2025-01-01).
- `endDate` (date, optional) — End date of event store to query to (e.g., 2025-02-01).

### RuntimeSourceConfig

- `sourceType` (enum, required) — Type of the source. Must match the actual source type in the meter definition.
  - Allowed values: `LOCAL_FS`, `S3`, `SNOWFLAKE`, `EVENT_STORE`
- `processorId` (string, optional) — ID of the source processor in the meter definition to apply this configuration to. Required when the meter has multiple sources of the same type.
- `localFs` (LocalFsOptions, optional) — Configuration options for LOCAL_FS sources (previously uploaded files).
- `s3` (S3Options, optional) — Configuration options for S3 sources (paths, connection).
- `snowflake` (SnowflakeOptions, optional) — Configuration options for Snowflake sources.
- `eventStore` (EventStoreOptions, optional) — Configuration options for EventStore sources (date range).

### RunMeterVersionResponseData

- `id` (string, optional) — Internal run history ID, unique within tenant.
- `sessionId` (string, optional) — Corresponding session ID of this run.
- `jobId` (string, optional) — Corresponding job ID of this run.
- `meterId` (integer, optional) — Internal meter ID.
- `version` (string, optional) — Version of the meter.
- `revision` (integer, optional) — Revision number of this version run.
- `runType` (integer, optional) — The run type: - 1. NORMAL - 2. DEBUG
- `runTypeDescription` (string, optional) — Description of the run type.
- `startTime` (datetime, optional) — Start time of this run.
- `endTime` (datetime, optional, nullable) — End time of this run.
- `status` (integer, optional) — The run status: - 1. NEVER_RUN - 2. TESTING - 3. TESTING_FAILED - 4. TESTING_PASSED - 5. RUNNING - 6. PAUSED - 7. COMPLETED - 8. FAILED - 9. CANCELED - 10. INITIALIZING - 11. USAGE_PUSHING - 12. PUSH_COMPLETED - 13. CONSUME_COMPLETED
- `statusDescription` (string, optional) — Description of the run status.
- `canExportSummary` (boolean, optional) — Whether the summary is ready to export.
- `hasLineageEnabled` (boolean, optional) — Whether lineage feature is enabled on this run.

### Error

- `code` (string, optional) — Machine-readable error code identifying the failure type.
- `message` (string, optional) — Human-readable description of the error that provides more context about what went wrong.
- `detail` (ErrorDetail, optional) — Additional structured details about the error, such as validation issues or parameter-specific information.

### ProxyBadRequestResponseErrorsItems

- `code` (string, optional) — Machine-readable error code identifying the failure type.
- `message` (string, optional) — Human-readable description of the error that provides more context about what went wrong.

### ErrorResponseReasonsItems

- `code` (string, optional) — The error code of response.
- `message` (string, optional) — The detail information of the error response

### LocalFsOptions

Configuration options for LOCAL_FS sources (previously uploaded files).

- `fileId` (long, required) — The ID of the file uploaded through the "Upload a file" operation, to be used as the source.

### S3Options

Configuration options for S3 sources (paths, connection).

- `paths` (list of string, required) — List of S3 paths to read from.
- `fileFormat` (enum, required) — Format of the input files.
  - Allowed values: `CSV`, `EXCEL`, `PARQUET`, `JSON`, `XML`, `AVRO`
- `connectionName` (string, optional) — Name of the S3 connection to use.
- `connectionVersion` (integer, optional) — Version of the S3 connection.
- `incremental` (boolean, optional) — Enables incremental mode to continuously monitor for new files. When `false`, files are processed only once.
- `monitorInterval` (integer, optional) — Interval in milliseconds for checking for new files when incremental mode is enabled. This field is applicable only when `incremental` is set to `true`.
- `retentionTime` (long, optional) — Retention time in milliseconds for processed files.
- `batchSize` (integer, optional) — Batch size for reading files.

### SnowflakeOptions

Configuration options for Snowflake sources.

- `database` (string, optional) — Snowflake database name.
- `schema` (string, optional) — Snowflake schema name.
- `table` (string, optional) — Snowflake table name.
- `query` (string, optional) — Custom SQL query to execute (SELECT only).
- `warehouse` (string, optional) — Snowflake warehouse to use.
- `role` (string, optional) — Snowflake role to use.
- `unloadFileFormat` (enum, optional) — File format for UNLOAD operation.
  - Allowed values: `CSV`, `EXCEL`, `PARQUET`, `JSON`, `XML`, `AVRO`
- `queryParameters` (map from string to SnowflakeOptionsQueryParameters, optional) — Parameter values for parameterized queries (:paramName syntax).

### EventStoreOptions

Configuration options for EventStore sources (date range).

- `storeId` (string, required) — Event store ID to read from.
- `startDate` (string, optional) — Start date for partition pruning (YYYY-MM-DD).
- `endDate` (string, optional) — End date for partition pruning (YYYY-MM-DD).
- `query` (string, optional) — Ad-hoc SQL query for Event Store (SELECT only, mutually exclusive with date range).

### ErrorDetail

Additional structured details about the error, such as validation issues or parameter-specific information.

### SnowflakeOptionsQueryParameters

Parameter values for parameterized queries (:paramName syntax).

## Examples

**Request**

```json
{}
```

**Response**

```json
{
  "success": true,
  "data": {
    "id": "5468",
    "sessionId": "R-00005468",
    "jobId": "da0b43468d6a41eaad03e559d6aecceb",
    "meterId": 2470,
    "version": "0.0.1",
    "revision": 1,
    "runType": 1,
    "runTypeDescription": "NORMAL",
    "startTime": "2025-03-31T09:17:21.192927441Z",
    "status": 10,
    "statusDescription": "INITIALIZING",
    "canExportSummary": false,
    "hasLineageEnabled": false
  },
  "previousPage": "null",
  "nextPage": "null"
}
```

**SDK Code**

```python Meter run success example
import requests

url = "https://rest.test.zuora.com/meters/run/meterId/0.0.1"

payload = {}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Meter run success example
const url = 'https://rest.test.zuora.com/meters/run/meterId/0.0.1';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Meter run success example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://rest.test.zuora.com/meters/run/meterId/0.0.1"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Meter run success example
require 'uri'
require 'net/http'

url = URI("https://rest.test.zuora.com/meters/run/meterId/0.0.1")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{}"

response = http.request(request)
puts response.read_body
```

```java Meter run success example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://rest.test.zuora.com/meters/run/meterId/0.0.1")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php Meter run success example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://rest.test.zuora.com/meters/run/meterId/0.0.1', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Meter run success example
using RestSharp;

var client = new RestClient("https://rest.test.zuora.com/meters/run/meterId/0.0.1");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Meter run success example
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://rest.test.zuora.com/meters/run/meterId/0.0.1")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```