TrylleDocs
API ReferenceOpenAPI 3 reference

Organization usage and billing

GET
/v1/orgs/{org}/accounting

Return an organization's accounting balances and insolvency state.

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

org*string
Length1 <= length

Response Body

application/json

curl -X GET "https://example.com/v1/orgs/aa/accounting"
{  "balance": {    "aiCreditMicrousd": 1,    "ciCreditMicrousd": 1,    "hardMicrousd": 1,    "hasUnpricedUsage": false,    "insolvent": false,    "pendingAiMicrousd": 1,    "pendingCiMicrousd": 1,    "pendingMicrousd": 1,    "softMicrousd": 1,    "totalMicrousd": 1  },  "ownerId": "abc123",  "ownerType": "organization"}
GET
/v1/orgs/{org}/accounting/charges

List organization daily charge allocations, optionally by category.

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

org*string
Length1 <= length

Query Parameters

category?string

Optional spending category.

Value in

  • "ai"
  • "ci"
limit?integer

Maximum daily allocation rows.

Formatint64
Range1 <= value <= 500
Default100

Response Body

application/json

curl -X GET "https://example.com/v1/orgs/aa/accounting/charges?category=ci&limit=2"
{  "items": [    {      "amountMicrousd": 1,      "category": "ci",      "date": "1970-01-01",      "fundingSource": "soft"    }  ]}
GET
/v1/orgs/{org}/accounting/chart

Return organization resource spending chart data.

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

org*string
Length1 <= length

Query Parameters

timeframe?string

Chart timeframe.

Default"last_24_hours"

Value in

  • "last_24_hours"
  • "last_7_days"
  • "month_to_date"

Response Body

application/json

curl -X GET "https://example.com/v1/orgs/aa/accounting/chart?timeframe=last_7_days"
{  "from": "1970-01-01T00:00:01Z",  "points": [    {      "aiCacheReadTokens": 1,      "aiCacheWriteTokens": 1,      "aiInputTokens": 1,      "aiMicrousd": 1,      "aiOutputTokens": 1,      "ciMicrousd": 1,      "ciMinutes": 1,      "hasUnpricedUsage": false,      "timestamp": "1970-01-01T00:00:01Z",      "totalMicrousd": 1    }  ],  "timeframe": "last_7_days",  "to": "1970-01-01T00:00:01Z"}
POST
/v1/orgs/{org}/accounting/coupons/redeem

Redeem a category-specific coupon for an organization.

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

org*string
Length1 <= length

Request Body

application/json

Coupon redemption request body.

TypeScript Definitions

Use the request body type in TypeScript.

Category-credit coupon redemption request.

Response Body

application/json

curl -X POST "https://example.com/v1/orgs/aa/accounting/coupons/redeem" \  -H "Content-Type: application/json" \  -d '{    "code": "aa"  }'
{  "amountMicrousd": 1,  "balance": {    "aiCreditMicrousd": 1,    "ciCreditMicrousd": 1,    "hardMicrousd": 1,    "hasUnpricedUsage": false,    "insolvent": false,    "pendingAiMicrousd": 1,    "pendingCiMicrousd": 1,    "pendingMicrousd": 1,    "softMicrousd": 1,    "totalMicrousd": 1  },  "category": "ci",  "code": "abc123"}
GET
/v1/orgs/{org}/billing

Billing summary for an organization.

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

org*string

Organization handle or Forgejo login.

Length1 <= length

Response Body

application/json

curl -X GET "https://example.com/v1/orgs/aa/billing"
"abc123"
POST
/v1/orgs/{org}/billing/checkout

Start Stripe Checkout for an organization subscription plan.

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

org*string

Organization handle or Forgejo login.

Length1 <= length

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

curl -X POST "https://example.com/v1/orgs/aa/billing/checkout" \  -H "Content-Type: application/json" \  -d '{    "cancelUrl": "aa",    "planKey": "aa",    "successUrl": "aa"  }'
"abc123"
POST
/v1/orgs/{org}/billing/portal

Open the Stripe customer portal for an organization.

Authorization

bearerAuth
AuthorizationBearer <token>

In: header

Path Parameters

org*string

Organization handle or Forgejo login.

Length1 <= length

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

curl -X POST "https://example.com/v1/orgs/aa/billing/portal" \  -H "Content-Type: application/json" \  -d '{    "returnUrl": "aa"  }'
"abc123"