API/Billing
Manage a subscription
POST/v1/billing/portal-sessions· API key
Returns a link to Stripe's hosted customer portal, where the plan can be changed or cancelled, the payment method updated and invoices downloaded. There is no billing screen of our own, and this link is the whole of billing management.
curl -X POST https://api.einvoicing.dev/v1/billing/portal-sessions \ -H "Authorization: Bearer $EINVOICING_API_KEY"<?php$client = new GuzzleHttp\Client();$response = $client->request('POST', 'https://api.einvoicing.dev/v1/billing/portal-sessions', [ 'headers' => [ 'Authorization' => 'Bearer ' . getenv('EINVOICING_API_KEY'), ],]);$data = json_decode((string) $response->getBody(), true)['data'];req, _ := http.NewRequest(http.MethodPost, "https://api.einvoicing.dev/v1/billing/portal-sessions", nil)req.Header.Set("Authorization", "Bearer "+os.Getenv("EINVOICING_API_KEY"))res, err := http.DefaultClient.Do(req)if err != nil { log.Fatal(err)}defer res.Body.Close()const res = await fetch("https://api.einvoicing.dev/v1/billing/portal-sessions", { method: "POST", headers: { Authorization: `Bearer ${process.env.EINVOICING_API_KEY}`, },});const { data } = await res.json();Response
201 A portal session was created.
| Field | Type | Description |
|---|---|---|
datarequired | BillingSession | A link to a Stripe-hosted billing page. |
{ "data": { "url": "https://billing.stripe.com/p/session/bps_a1B2c3D4", "expires_at": null }}Errors
Every error is application/problem+json (RFC 9457). Branch on type, which is stable, never on title or detail.
| Status | When |
|---|---|
| 401 | No key, or a key that is unknown or revoked. Problem |
| 403 | A test key cannot manage keys or billing. Use a live key. Problem
|
| 409 | The account is on the Free plan and has nothing to manage. Start one with a checkout session. Problem |
| 429 | Too many requests in a short window. Slow down and retry after the
number of seconds in |
Schemas
BillingSession
A link to a Stripe-hosted billing page.
| Field | Type | Description |
|---|---|---|
urlrequired | string · uri | Open this in a browser. |
expires_atrequired | string or null · date-time | When the link stops working, if Stripe says. |