For clean Markdown of any page, append .md to the page URL. For a complete documentation index, see https://docs.prolifi.io/endpoints/usage-events/llms.txt. For full documentation content, see https://docs.prolifi.io/endpoints/usage-events/llms-full.txt.

# Batch report usage events

POST https://api.prolifi.co/api/v1/public/events/batch
Content-Type: application/json

Reports multiple usage events in a single request. Accepts 1 to 1,000 events per batch.

Each event is processed independently — some may succeed while others fail. The response includes counts of accepted and rejected events, along with error details for any failures.


Reference: https://docs.prolifi.io/endpoints/usage-events/batch-report-usage-events

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Prolifi Public API
  version: 1.0.0
paths:
  /events/batch:
    post:
      operationId: batch-report-usage-events
      summary: Batch report usage events
      description: >
        Reports multiple usage events in a single request. Accepts 1 to 1,000
        events per batch.


        Each event is processed independently — some may succeed while others
        fail. The response includes counts of accepted and rejected events,
        along with error details for any failures.
      tags:
        - subpackage_usageEvents
      parameters:
        - name: Authorization
          in: header
          description: >
            Use a secret key (`sk_test_*` or `sk_live_*`) for full read/write
            access, or a public key (`pk_test_*` or `pk_live_*`) for read-only
            access.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Batch processed
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/Usage
                  Events_batchReportUsageEvents_Response_200
        '401':
          description: Authentication failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Permission denied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '422':
          description: Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BatchReportUsageEventsRequest'
servers:
  - url: https://api.prolifi.co/api/v1/public
  - url: https://sandbox.prolifi.co/api/v1/public
components:
  schemas:
    ReportUsageEventRequest:
      type: object
      properties:
        customer_id:
          type: string
          format: uuid
          description: The customer who performed the action.
        event_name:
          type: string
          description: >-
            The name or ID of the usage event definition. Must match an active
            event in your account.
        subscription_id:
          type:
            - string
            - 'null'
          format: uuid
          description: Optional subscription to associate the event with.
        timestamp:
          type:
            - string
            - 'null'
          format: date-time
          description: When the event occurred. Defaults to the current time.
        properties:
          type:
            - object
            - 'null'
          additionalProperties:
            description: Any type
          description: Custom key-value properties for the event.
        idempotency_key:
          type:
            - string
            - 'null'
          description: Unique key to prevent duplicate event processing.
      required:
        - customer_id
        - event_name
      title: ReportUsageEventRequest
    BatchReportUsageEventsRequest:
      type: object
      properties:
        events:
          type: array
          items:
            $ref: '#/components/schemas/ReportUsageEventRequest'
          description: Array of usage events to report (1-1,000 per batch).
      required:
        - events
      title: BatchReportUsageEventsRequest
    BatchUsageEventResponseErrorsItems:
      type: object
      properties:
        index:
          type: integer
          description: Zero-based index of the failed event in the input array.
        message:
          type: string
          description: Error message.
      title: BatchUsageEventResponseErrorsItems
    BatchUsageEventResponse:
      type: object
      properties:
        accepted:
          type: integer
          description: Number of events successfully processed.
        rejected:
          type: integer
          description: Number of events that failed.
        errors:
          type: array
          items:
            $ref: '#/components/schemas/BatchUsageEventResponseErrorsItems'
          description: Details of rejected events.
      title: BatchUsageEventResponse
    Usage Events_batchReportUsageEvents_Response_200:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/BatchUsageEventResponse'
      title: Usage Events_batchReportUsageEvents_Response_200
    ErrorResponseErrorType:
      type: string
      enum:
        - authentication_error
        - permission_error
        - validation_error
        - not_found
        - invalid_request
        - rate_limit_error
        - ip_restricted
        - conflict
        - api_error
      description: Machine-readable error type.
      title: ErrorResponseErrorType
    ErrorResponseErrorErrorsItems:
      type: object
      properties:
        field:
          type: string
          description: The field that failed validation.
        message:
          type: string
          description: The validation error message.
      title: ErrorResponseErrorErrorsItems
    ErrorResponseError:
      type: object
      properties:
        type:
          $ref: '#/components/schemas/ErrorResponseErrorType'
          description: Machine-readable error type.
        message:
          type: string
          description: Human-readable error description.
        errors:
          type: array
          items:
            $ref: '#/components/schemas/ErrorResponseErrorErrorsItems'
          description: >-
            Field-level validation errors (only present for `validation_error`
            type).
      required:
        - type
        - message
      title: ErrorResponseError
    ErrorResponse:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/ErrorResponseError'
      title: ErrorResponse
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >
        Use a secret key (`sk_test_*` or `sk_live_*`) for full read/write
        access, or a public key (`pk_test_*` or `pk_live_*`) for read-only
        access.

```

## SDK Code Examples

```python All events accepted
import requests

url = "https://api.prolifi.co/api/v1/public/events/batch"

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

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

print(response.json())
```

```javascript All events accepted
const url = 'https://api.prolifi.co/api/v1/public/events/batch';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: undefined
};

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

```go All events accepted
package main

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

func main() {

	url := "https://api.prolifi.co/api/v1/public/events/batch"

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

	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 All events accepted
require 'uri'
require 'net/http'

url = URI("https://api.prolifi.co/api/v1/public/events/batch")

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'

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

```java All events accepted
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.prolifi.co/api/v1/public/events/batch")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .asString();
```

```php All events accepted
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.prolifi.co/api/v1/public/events/batch', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp All events accepted
using RestSharp;

var client = new RestClient("https://api.prolifi.co/api/v1/public/events/batch");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
```

```swift All events accepted
import Foundation

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.prolifi.co/api/v1/public/events/batch")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

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()
```

```python Some events rejected
import requests

url = "https://api.prolifi.co/api/v1/public/events/batch"

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

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

print(response.json())
```

```javascript Some events rejected
const url = 'https://api.prolifi.co/api/v1/public/events/batch';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: undefined
};

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

```go Some events rejected
package main

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

func main() {

	url := "https://api.prolifi.co/api/v1/public/events/batch"

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

	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 Some events rejected
require 'uri'
require 'net/http'

url = URI("https://api.prolifi.co/api/v1/public/events/batch")

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'

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

```java Some events rejected
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.prolifi.co/api/v1/public/events/batch")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .asString();
```

```php Some events rejected
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.prolifi.co/api/v1/public/events/batch', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Some events rejected
using RestSharp;

var client = new RestClient("https://api.prolifi.co/api/v1/public/events/batch");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(request);
```

```swift Some events rejected
import Foundation

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.prolifi.co/api/v1/public/events/batch")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

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()
```

```python Report multiple events
import requests

url = "https://api.prolifi.co/api/v1/public/events/batch"

payload = { "events": [
        {
            "customer_id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
            "event_name": "api_calls",
            "properties": { "endpoint": "/v1/chat" }
        },
        {
            "customer_id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
            "event_name": "api_calls",
            "properties": { "endpoint": "/v1/embeddings" }
        }
    ] }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Report multiple events
const url = 'https://api.prolifi.co/api/v1/public/events/batch';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"events":[{"customer_id":"d290f1ee-6c54-4b01-90e6-d701748f0851","event_name":"api_calls","properties":{"endpoint":"/v1/chat"}},{"customer_id":"d290f1ee-6c54-4b01-90e6-d701748f0851","event_name":"api_calls","properties":{"endpoint":"/v1/embeddings"}}]}'
};

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

```go Report multiple events
package main

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

func main() {

	url := "https://api.prolifi.co/api/v1/public/events/batch"

	payload := strings.NewReader("{\n  \"events\": [\n    {\n      \"customer_id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\",\n      \"event_name\": \"api_calls\",\n      \"properties\": {\n        \"endpoint\": \"/v1/chat\"\n      }\n    },\n    {\n      \"customer_id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\",\n      \"event_name\": \"api_calls\",\n      \"properties\": {\n        \"endpoint\": \"/v1/embeddings\"\n      }\n    }\n  ]\n}")

	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 Report multiple events
require 'uri'
require 'net/http'

url = URI("https://api.prolifi.co/api/v1/public/events/batch")

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 = "{\n  \"events\": [\n    {\n      \"customer_id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\",\n      \"event_name\": \"api_calls\",\n      \"properties\": {\n        \"endpoint\": \"/v1/chat\"\n      }\n    },\n    {\n      \"customer_id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\",\n      \"event_name\": \"api_calls\",\n      \"properties\": {\n        \"endpoint\": \"/v1/embeddings\"\n      }\n    }\n  ]\n}"

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

```java Report multiple events
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.prolifi.co/api/v1/public/events/batch")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"events\": [\n    {\n      \"customer_id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\",\n      \"event_name\": \"api_calls\",\n      \"properties\": {\n        \"endpoint\": \"/v1/chat\"\n      }\n    },\n    {\n      \"customer_id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\",\n      \"event_name\": \"api_calls\",\n      \"properties\": {\n        \"endpoint\": \"/v1/embeddings\"\n      }\n    }\n  ]\n}")
  .asString();
```

```php Report multiple events
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.prolifi.co/api/v1/public/events/batch', [
  'body' => '{
  "events": [
    {
      "customer_id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
      "event_name": "api_calls",
      "properties": {
        "endpoint": "/v1/chat"
      }
    },
    {
      "customer_id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
      "event_name": "api_calls",
      "properties": {
        "endpoint": "/v1/embeddings"
      }
    }
  ]
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Report multiple events
using RestSharp;

var client = new RestClient("https://api.prolifi.co/api/v1/public/events/batch");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"events\": [\n    {\n      \"customer_id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\",\n      \"event_name\": \"api_calls\",\n      \"properties\": {\n        \"endpoint\": \"/v1/chat\"\n      }\n    },\n    {\n      \"customer_id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\",\n      \"event_name\": \"api_calls\",\n      \"properties\": {\n        \"endpoint\": \"/v1/embeddings\"\n      }\n    }\n  ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Report multiple events
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["events": [
    [
      "customer_id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
      "event_name": "api_calls",
      "properties": ["endpoint": "/v1/chat"]
    ],
    [
      "customer_id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
      "event_name": "api_calls",
      "properties": ["endpoint": "/v1/embeddings"]
    ]
  ]] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.prolifi.co/api/v1/public/events/batch")! 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()
```