TinyMCE AI Usage API
The Usage API returns the credits that the TinyMCE AI service recorded for an environment over a period of time. A request can also return the credits for each listed user, or for every user with activity in the period.
The endpoint is POST /v1/admin/billing/usage. It is an administration endpoint: back-end code calls it with an administration token. The tinymceai plugin does not call it.
Requirements
-
Deployment: the Tiny Cloud-hosted TinyMCE AI service. The usage is reported for the environment that the token identifies in its
audclaim. -
Token: a token that grants
ai:admin, signed and used only on a back end. See Admin permissions.
Get usage
-
Sign an administration token on the back end. Sign it with a JWT signing key of the Tiny Cloud API key, in the same way as user tokens (see JWT authentication), and include
ai:adminin the permissions. -
Send
POST /v1/admin/billing/usagetohttps://tinymceai.api.tiny.cloudwith the period to report on. Setusersto the string"*"to report on every user with activity in the period. -
Read the
environmentobject for the environment total, and theusersarray for the credits of each user.
A user ID in the request and the response is the sub claim of the tokens of that user.
For the request and response fields and the error codes, see Get billing usage in the API reference. Errors use the body described in Error responses.
Related features
-
Admin permissions: The
ai:adminpermission and how to handle administration tokens. -
JWT authentication: Token claims, including
audandsub. -
Limits: Rate limits, context limits, and file limits.
-
API overview: The features of the TinyMCE AI REST API and the conventions they share.
-
Billing API: Request and response schemas, and error codes.