Auth and Record

Auth And Record

Important

The usage record keys are used to aggregate usage record values. There is a limit of 5000 unique usage record keys per usage store per hour. If you exceed this limit, some usage record keys will be ignored.

import { authAndRecord } from "usage-api";
 
const res = authAndRecord(
    process.env.USAGE_API_KEY,
    usageStoreApiKey, // api key from the user
    {
        usageRecords: [ // required, max 10 usage records per request
            {
                key: "Usage_Record_Key", // required
                value: 1 // required
            },
            {
                key: "Usage_Record_Key_the_second",
                value: 0.001
            }
        ]
        blockBehavior: "ignore" | "block" // default block
    }
);
 
type res = {
    success: true,
} | {
    success: false,
    message: string
}