Skip to main content
PUT
/
usage-metrics
/
{id}
Update a Usage Metric
curl --request PUT \
  --url https://eu.sequencehq.com/api/usage-metrics/{id} \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "Total length of sent messages.",
  "description": "Total length of sent messages.",
  "metricType": "GROUPED",
  "eventType": "message_sent",
  "aggregationType": "COUNT",
  "aggregationProperty": "message_length",
  "groupingProperty": "channel",
  "unit": "bytes",
  "propertyFilters": {
    "channels": [
      "text",
      "email"
    ]
  },
  "caseSensitive": true,
  "propertiesToNegate": [
    "channels"
  ]
}
'
import requests

url = "https://eu.sequencehq.com/api/usage-metrics/{id}"

payload = {
"name": "Total length of sent messages.",
"description": "Total length of sent messages.",
"metricType": "GROUPED",
"eventType": "message_sent",
"aggregationType": "COUNT",
"aggregationProperty": "message_length",
"groupingProperty": "channel",
"unit": "bytes",
"propertyFilters": { "channels": ["text", "email"] },
"caseSensitive": True,
"propertiesToNegate": ["channels"]
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}

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

print(response.text)
const options = {
method: 'PUT',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Total length of sent messages.',
description: 'Total length of sent messages.',
metricType: 'GROUPED',
eventType: 'message_sent',
aggregationType: 'COUNT',
aggregationProperty: 'message_length',
groupingProperty: 'channel',
unit: 'bytes',
propertyFilters: {channels: ['text', 'email']},
caseSensitive: true,
propertiesToNegate: ['channels']
})
};

fetch('https://eu.sequencehq.com/api/usage-metrics/{id}', 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-metrics/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Total length of sent messages.',
'description' => 'Total length of sent messages.',
'metricType' => 'GROUPED',
'eventType' => 'message_sent',
'aggregationType' => 'COUNT',
'aggregationProperty' => 'message_length',
'groupingProperty' => 'channel',
'unit' => 'bytes',
'propertyFilters' => [
'channels' => [
'text',
'email'
]
],
'caseSensitive' => true,
'propertiesToNegate' => [
'channels'
]
]),
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-metrics/{id}"

payload := strings.NewReader("{\n \"name\": \"Total length of sent messages.\",\n \"description\": \"Total length of sent messages.\",\n \"metricType\": \"GROUPED\",\n \"eventType\": \"message_sent\",\n \"aggregationType\": \"COUNT\",\n \"aggregationProperty\": \"message_length\",\n \"groupingProperty\": \"channel\",\n \"unit\": \"bytes\",\n \"propertyFilters\": {\n \"channels\": [\n \"text\",\n \"email\"\n ]\n },\n \"caseSensitive\": true,\n \"propertiesToNegate\": [\n \"channels\"\n ]\n}")

req, _ := http.NewRequest("PUT", 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.put("https://eu.sequencehq.com/api/usage-metrics/{id}")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Total length of sent messages.\",\n \"description\": \"Total length of sent messages.\",\n \"metricType\": \"GROUPED\",\n \"eventType\": \"message_sent\",\n \"aggregationType\": \"COUNT\",\n \"aggregationProperty\": \"message_length\",\n \"groupingProperty\": \"channel\",\n \"unit\": \"bytes\",\n \"propertyFilters\": {\n \"channels\": [\n \"text\",\n \"email\"\n ]\n },\n \"caseSensitive\": true,\n \"propertiesToNegate\": [\n \"channels\"\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://eu.sequencehq.com/api/usage-metrics/{id}")

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

request = Net::HTTP::Put.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Total length of sent messages.\",\n \"description\": \"Total length of sent messages.\",\n \"metricType\": \"GROUPED\",\n \"eventType\": \"message_sent\",\n \"aggregationType\": \"COUNT\",\n \"aggregationProperty\": \"message_length\",\n \"groupingProperty\": \"channel\",\n \"unit\": \"bytes\",\n \"propertyFilters\": {\n \"channels\": [\n \"text\",\n \"email\"\n ]\n },\n \"caseSensitive\": true,\n \"propertiesToNegate\": [\n \"channels\"\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "id": "f092246c-6b90-4106-bcca-304ccf06bf45",
  "sequenceAccountId": "ec1479a2-6ba1-421f-a7de-0853a20d17a1",
  "name": "Total length of sent messages.",
  "description": "Total length of sent messages.",
  "metricType": "GROUPED",
  "eventType": "message_sent",
  "aggregationType": "COUNT",
  "aggregationProperty": "message_length",
  "groupingProperty": "channel",
  "unit": "bytes",
  "createdAt": "2022-06-28T16:47:00Z",
  "deletedAt": "2022-06-28T16:47:00Z",
  "propertyFilters": {
    "channels": [
      "text",
      "email"
    ]
  },
  "caseSensitive": true,
  "propertiesToNegate": [
    "channels"
  ],
  "parameters": [
    {
      "id": "2963e49a-c8e0-4673-89f5-7a805c0faf14",
      "usageMetricId": "f092246c-6b90-4106-bcca-304ccf06bf45",
      "name": "myParam",
      "type": "INTEGER",
      "description": "My parameter",
      "defaultValue": "10"
    }
  ]
}
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

Path Parameters

id
string
required

Unique ID

Body

application/json
name
string
required

Human-readable name for this metric, which should be unique

Example:

"Total length of sent messages."

metricType
enum<string>
required

Type of metric (simple or grouped)

Available options:
SIMPLE,
GROUPED
Example:

"GROUPED"

eventType
string
required

The eventType of the Usage Event to be aggregated

Example:

"message_sent"

aggregationType
enum<string>
required

Type of aggregation to perform

Available options:
COUNT,
UNIQUE,
SUM,
CUSTOM
Example:

"COUNT"

description
string

Description for this metric

Example:

"Total length of sent messages."

aggregationProperty
string

Property within the event to aggregate

Example:

"message_length"

groupingProperty
string

Property within the event to group results by

Example:

"channel"

unit
string

Human-readable unit of the aggregated metric, eg. API calls)

Example:

"bytes"

propertyFilters
object

propertyFilters

caseSensitive
boolean

caseSensitive

Example:

true

propertiesToNegate
string[]

propertiesToNegate

Example:
["channels"]

Response

OK

id
string
required

Unique ID

Example:

"f092246c-6b90-4106-bcca-304ccf06bf45"

sequenceAccountId
string
required

Sequence Account ID

Example:

"ec1479a2-6ba1-421f-a7de-0853a20d17a1"

name
string
required

Human-readable name for this metric, which should be unique

Example:

"Total length of sent messages."

metricType
enum<string>
required

Type of metric (simple or grouped)

Available options:
SIMPLE,
GROUPED
Example:

"GROUPED"

eventType
string
required

The eventType of the Usage Event to be aggregated

Example:

"message_sent"

aggregationType
enum<string>
required

Type of aggregation to perform

Available options:
COUNT,
UNIQUE,
SUM,
CUSTOM
Example:

"COUNT"

propertyFilters
object
required

propertyFilters

parameters
object[]
required

Required parameters

Example:
[
{
"id": "2963e49a-c8e0-4673-89f5-7a805c0faf14",
"usageMetricId": "f092246c-6b90-4106-bcca-304ccf06bf45",
"name": "myParam",
"type": "INTEGER",
"description": "My parameter",
"defaultValue": "10"
}
]
description
string

Description for this metric

Example:

"Total length of sent messages."

aggregationProperty
string

Property within the event to aggregate

Example:

"message_length"

groupingProperty
string

Property within the event to group results by

Example:

"channel"

unit
string

Human-readable unit of the aggregated metric, eg. API calls)

Example:

"bytes"

createdAt
string

Created at

Example:

"2022-06-28T16:47:00Z"

deletedAt
string

Created at

Example:

"2022-06-28T16:47:00Z"

caseSensitive
boolean

caseSensitive

Example:

true

propertiesToNegate
string[]

propertiesToNegate

Example:
["channels"]