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.

# Report a usage event

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

Reports a single usage event for a customer. The `event_name` must match an active usage event definition configured for your account.

If no `properties` are provided, a default `count: 1` property is added automatically.


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

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Prolifi Public API
  version: 1.0.0
paths:
  /events:
    post:
      operationId: report-usage-event
      summary: Report a usage event
      description: >
        Reports a single usage event for a customer. The `event_name` must match
        an active usage event definition configured for your account.


        If no `properties` are provided, a default `count: 1` property is added
        automatically.
      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:
        '201':
          description: Usage event reported successfully
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/Usage
                  Events_reportUsageEvent_Response_201
        '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'
        '500':
          description: Usage event name not found or processing error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ReportUsageEventRequest'
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
    UsageEvent:
      type: object
      properties: {}
      title: UsageEvent
    Usage Events_reportUsageEvent_Response_201:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/UsageEvent'
      title: Usage Events_reportUsageEvent_Response_201
    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 Report with custom properties
import requests

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

payload = {
    "customer_id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
    "event_name": "api_calls",
    "subscription_id": "a1b2c3d4-5678-90ab-cdef-1234567890ab",
    "timestamp": "2026-03-13T14:30:00Z",
    "properties": {
        "endpoint": "/v1/completions",
        "tokens": 150
    },
    "idempotency_key": "evt_unique_12345"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Report with custom properties
const url = 'https://api.prolifi.co/api/v1/public/events';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"customer_id":"d290f1ee-6c54-4b01-90e6-d701748f0851","event_name":"api_calls","subscription_id":"a1b2c3d4-5678-90ab-cdef-1234567890ab","timestamp":"2026-03-13T14:30:00Z","properties":{"endpoint":"/v1/completions","tokens":150},"idempotency_key":"evt_unique_12345"}'
};

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

```go Report with custom properties
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"customer_id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\",\n  \"event_name\": \"api_calls\",\n  \"subscription_id\": \"a1b2c3d4-5678-90ab-cdef-1234567890ab\",\n  \"timestamp\": \"2026-03-13T14:30:00Z\",\n  \"properties\": {\n    \"endpoint\": \"/v1/completions\",\n    \"tokens\": 150\n  },\n  \"idempotency_key\": \"evt_unique_12345\"\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 with custom properties
require 'uri'
require 'net/http'

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

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  \"customer_id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\",\n  \"event_name\": \"api_calls\",\n  \"subscription_id\": \"a1b2c3d4-5678-90ab-cdef-1234567890ab\",\n  \"timestamp\": \"2026-03-13T14:30:00Z\",\n  \"properties\": {\n    \"endpoint\": \"/v1/completions\",\n    \"tokens\": 150\n  },\n  \"idempotency_key\": \"evt_unique_12345\"\n}"

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

```java Report with custom properties
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")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"customer_id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\",\n  \"event_name\": \"api_calls\",\n  \"subscription_id\": \"a1b2c3d4-5678-90ab-cdef-1234567890ab\",\n  \"timestamp\": \"2026-03-13T14:30:00Z\",\n  \"properties\": {\n    \"endpoint\": \"/v1/completions\",\n    \"tokens\": 150\n  },\n  \"idempotency_key\": \"evt_unique_12345\"\n}")
  .asString();
```

```php Report with custom properties
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.prolifi.co/api/v1/public/events', [
  'body' => '{
  "customer_id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
  "event_name": "api_calls",
  "subscription_id": "a1b2c3d4-5678-90ab-cdef-1234567890ab",
  "timestamp": "2026-03-13T14:30:00Z",
  "properties": {
    "endpoint": "/v1/completions",
    "tokens": 150
  },
  "idempotency_key": "evt_unique_12345"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp Report with custom properties
using RestSharp;

var client = new RestClient("https://api.prolifi.co/api/v1/public/events");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"customer_id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\",\n  \"event_name\": \"api_calls\",\n  \"subscription_id\": \"a1b2c3d4-5678-90ab-cdef-1234567890ab\",\n  \"timestamp\": \"2026-03-13T14:30:00Z\",\n  \"properties\": {\n    \"endpoint\": \"/v1/completions\",\n    \"tokens\": 150\n  },\n  \"idempotency_key\": \"evt_unique_12345\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Report with custom properties
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = [
  "customer_id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
  "event_name": "api_calls",
  "subscription_id": "a1b2c3d4-5678-90ab-cdef-1234567890ab",
  "timestamp": "2026-03-13T14:30:00Z",
  "properties": [
    "endpoint": "/v1/completions",
    "tokens": 150
  ],
  "idempotency_key": "evt_unique_12345"
] as [String : Any]

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

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

```python
import requests

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

payload = {
    "customer_id": "d290f1ee-6c54-4b01-90e6-d701748f0851",
    "event_name": "api_calls"
}
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

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

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

```go
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"customer_id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\",\n  \"event_name\": \"api_calls\"\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
require 'uri'
require 'net/http'

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

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  \"customer_id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\",\n  \"event_name\": \"api_calls\"\n}"

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

```java
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")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"customer_id\": \"d290f1ee-6c54-4b01-90e6-d701748f0851\",\n  \"event_name\": \"api_calls\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

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

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

```csharp
using RestSharp;

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

```swift
import Foundation

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

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

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