Skip to main content
POST
/
meters
/
ingest
Ingest Meter Usage
curl --request POST \
  --url https://api.blink.store/v1/meters/ingest \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "event_name": "<string>",
  "quantity": 123,
  "customer_id": "<string>",
  "customer_email": "<string>",
  "subscription_id": "<string>",
  "action": "increment",
  "timestamp": "2023-11-07T05:31:56Z",
  "idempotency_key": "<string>"
}
'
import requests

url = "https://api.blink.store/v1/meters/ingest"

payload = {
"event_name": "<string>",
"quantity": 123,
"customer_id": "<string>",
"customer_email": "<string>",
"subscription_id": "<string>",
"action": "increment",
"timestamp": "2023-11-07T05:31:56Z",
"idempotency_key": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

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

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
event_name: '<string>',
quantity: 123,
customer_id: '<string>',
customer_email: '<string>',
subscription_id: '<string>',
action: 'increment',
timestamp: '2023-11-07T05:31:56Z',
idempotency_key: '<string>'
})
};

fetch('https://api.blink.store/v1/meters/ingest', 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://api.blink.store/v1/meters/ingest",
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([
'event_name' => '<string>',
'quantity' => 123,
'customer_id' => '<string>',
'customer_email' => '<string>',
'subscription_id' => '<string>',
'action' => 'increment',
'timestamp' => '2023-11-07T05:31:56Z',
'idempotency_key' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://api.blink.store/v1/meters/ingest"

payload := strings.NewReader("{\n \"event_name\": \"<string>\",\n \"quantity\": 123,\n \"customer_id\": \"<string>\",\n \"customer_email\": \"<string>\",\n \"subscription_id\": \"<string>\",\n \"action\": \"increment\",\n \"timestamp\": \"2023-11-07T05:31:56Z\",\n \"idempotency_key\": \"<string>\"\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(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.blink.store/v1/meters/ingest")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"event_name\": \"<string>\",\n \"quantity\": 123,\n \"customer_id\": \"<string>\",\n \"customer_email\": \"<string>\",\n \"subscription_id\": \"<string>\",\n \"action\": \"increment\",\n \"timestamp\": \"2023-11-07T05:31:56Z\",\n \"idempotency_key\": \"<string>\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.blink.store/v1/meters/ingest")

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 \"event_name\": \"<string>\",\n \"quantity\": 123,\n \"customer_id\": \"<string>\",\n \"customer_email\": \"<string>\",\n \"subscription_id\": \"<string>\",\n \"action\": \"increment\",\n \"timestamp\": \"2023-11-07T05:31:56Z\",\n \"idempotency_key\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body
{
  "success": true,
  "ingested": 123,
  "deducted_from_credits": 123,
  "overage": 123,
  "reported_to_stripe": true,
  "credits_remaining": 123
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
event_name
string
required

The name of the meter event to ingest.

quantity
integer
required

The amount of usage to record/deduct.

customer_id
string

The ID of the customer. Optional if email or subscription_id is provided.

customer_email
string

The email of the customer. Optional if customer_id or subscription_id is provided.

subscription_id
string

The ID of the subscription. Optional if customer_id or email is provided.

action
string
default:increment

The action to take.

timestamp
string<date-time>

The time the usage occurred.

idempotency_key
string

A unique key to prevent duplicate usage ingestion.

Response

Usage successfully ingested.

success
boolean
ingested
integer
deducted_from_credits
integer
overage
integer
reported_to_stripe
boolean
credits_remaining
integer