Skip to main content
POST
/
usage-events
Create a new Usage Event
curl --request POST \
  --url https://eu.sequencehq.com/api/usage-events \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "customerEventId": "event-id-H4twuTWpYx1rkd8OMTki2hTUcZ",
  "customerAlias": "customer-id-2H4u5BBwBWsS5V2sroRFqJfTXpW",
  "eventType": "message-sent",
  "eventTimestamp": "2022-10-01T00:00:00Z",
  "eventProperties": {
    "length": 500,
    "type": "text_message"
  }
}
'
import requests

url = "https://eu.sequencehq.com/api/usage-events"

payload = {
    "customerEventId": "event-id-H4twuTWpYx1rkd8OMTki2hTUcZ",
    "customerAlias": "customer-id-2H4u5BBwBWsS5V2sroRFqJfTXpW",
    "eventType": "message-sent",
    "eventTimestamp": "2022-10-01T00:00:00Z",
    "eventProperties": {
        "length": 500,
        "type": "text_message"
    }
}
headers = {
    "Authorization": "<authorization>",
    "Content-Type": "application/json"
}

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

print(response.text)
const options = {
  method: 'POST',
  headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    customerEventId: 'event-id-H4twuTWpYx1rkd8OMTki2hTUcZ',
    customerAlias: 'customer-id-2H4u5BBwBWsS5V2sroRFqJfTXpW',
    eventType: 'message-sent',
    eventTimestamp: '2022-10-01T00:00:00Z',
    eventProperties: {length: 500, type: 'text_message'}
  })
};

fetch('https://eu.sequencehq.com/api/usage-events', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://eu.sequencehq.com/api/usage-events",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'customerEventId' => 'event-id-H4twuTWpYx1rkd8OMTki2hTUcZ',
    'customerAlias' => 'customer-id-2H4u5BBwBWsS5V2sroRFqJfTXpW',
    'eventType' => 'message-sent',
    'eventTimestamp' => '2022-10-01T00:00:00Z',
    'eventProperties' => [
        'length' => 500,
        'type' => 'text_message'
    ]
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: <authorization>",
    "Content-Type: application/json"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

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

func main() {

	url := "https://eu.sequencehq.com/api/usage-events"

	payload := strings.NewReader("{\n  \"customerEventId\": \"event-id-H4twuTWpYx1rkd8OMTki2hTUcZ\",\n  \"customerAlias\": \"customer-id-2H4u5BBwBWsS5V2sroRFqJfTXpW\",\n  \"eventType\": \"message-sent\",\n  \"eventTimestamp\": \"2022-10-01T00:00:00Z\",\n  \"eventProperties\": {\n    \"length\": 500,\n    \"type\": \"text_message\"\n  }\n}")

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

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

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

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

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://eu.sequencehq.com/api/usage-events")
  .header("Authorization", "<authorization>")
  .header("Content-Type", "application/json")
  .body("{\n  \"customerEventId\": \"event-id-H4twuTWpYx1rkd8OMTki2hTUcZ\",\n  \"customerAlias\": \"customer-id-2H4u5BBwBWsS5V2sroRFqJfTXpW\",\n  \"eventType\": \"message-sent\",\n  \"eventTimestamp\": \"2022-10-01T00:00:00Z\",\n  \"eventProperties\": {\n    \"length\": 500,\n    \"type\": \"text_message\"\n  }\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://eu.sequencehq.com/api/usage-events")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"customerEventId\": \"event-id-H4twuTWpYx1rkd8OMTki2hTUcZ\",\n  \"customerAlias\": \"customer-id-2H4u5BBwBWsS5V2sroRFqJfTXpW\",\n  \"eventType\": \"message-sent\",\n  \"eventTimestamp\": \"2022-10-01T00:00:00Z\",\n  \"eventProperties\": {\n    \"length\": 500,\n    \"type\": \"text_message\"\n  }\n}"

response = http.request(request)
puts response.read_body
{
  "id": "0184421a-8202-70ea-a729-30308a40bbf7",
  "customerEventId": "event-id-H4twuTWpYx1rkd8OMTki2hTUcZ",
  "customerAlias": "customer-id-2H4u5BBwBWsS5V2sroRFqJfTXpW",
  "eventType": "message-sent",
  "sequenceAccountId": "0184421e-a9cc-711b-af93-bf0511d4d833",
  "eventTimestamp": "2022-10-01T00:00:00Z",
  "eventProperties": {
    "length": 500,
    "type": "text_message"
  }
}
This response has no body data.
This response has no body data.
This response has no body data.

Headers

Authorization
string
required

Your API credentials. Eg. Basic {credentials}.

Sequence-Version
enum<string>

Use this header to select an API version

Available options:
2024-07-30

Body

application/json
customerAlias
string
required

End-customer alias or ID

Example:

"customer-id-2H4u5BBwBWsS5V2sroRFqJfTXpW"

eventType
string
required

Event type. This can be referenced from a usage metric.

Example:

"message-sent"

customerEventId
string

ID provided by customer. Another event with the same customer event ID will supersede this one.

Example:

"event-id-H4twuTWpYx1rkd8OMTki2hTUcZ"

eventTimestamp
string

Event timestamp, in ISO 8601 format.

Example:

"2022-10-01T00:00:00Z"

eventProperties
object

Event properties. These can be referenced by a usage metric.

Response

Created

id
string
required

Unique ID

Example:

"0184421a-8202-70ea-a729-30308a40bbf7"

customerEventId
string
required

ID provided by customer. Another event with the same customer event ID will supersede this one.

Example:

"event-id-H4twuTWpYx1rkd8OMTki2hTUcZ"

customerAlias
string
required

End-customer alias or ID

Example:

"customer-id-2H4u5BBwBWsS5V2sroRFqJfTXpW"

eventType
string
required

Event type. This can be referenced from a usage metric.

Example:

"message-sent"

sequenceAccountId
string
required

Sequence account ID

Example:

"0184421e-a9cc-711b-af93-bf0511d4d833"

eventTimestamp
string
required

Event timestamp, in ISO 8601 format.

Example:

"2022-10-01T00:00:00Z"

eventProperties
object
required

Event properties. These can be referenced by a usage metric.