Skip to main content

POST /api/v1/apps/:appUuid/tenants/:tenantUuid/payment-providers/:paymentProvider/billing-portals

Creates a new billing portals resource from a server-side app integration.

This endpoint documentation is generated from the current Fastify route implementation and should be treated as the implementation-level contract for this version of the API.

Source route file: src/api/routes/external/private/apiKey/app/tenants/paymentProviders/billing-portals/post.ts

Request Method

POST

Base URL

https://api.userdocks.local:5000

Endpoint

/api/v1/apps/:appUuid/tenants/:tenantUuid/payment-providers/:paymentProvider/billing-portals

Path Variables

VariableTypeRequiredDescription
appUuidstringtruePath variable from route pattern.
tenantUuidstringtruePath variable from route pattern.
paymentProviderstringtrueUse stripe or mollie.

Query Parameters

No query parameters.

HTTP Headers

VariableTypeRequiredDescription
x-api-keystringtrueAPI key value for the app.
x-client-idstringtrueMust match :appUuid path variable.
x-api-key-typestringtrueUse write.
Content-TypestringtrueUse application/json for JSON request bodies.

Request Body

Schema reference: createBillingPortalSchema, without tenantUuid. The tenant is resolved from the :tenantUuid path variable.

{
"defaultReturnUrl": "https://app.example.com/account"
}

Successful Response

Success status code(s): 200.

{
"kind": "billingPortal",
"totalItems": 1,
"itemsLength": 1,
"items": [
{
"nextAction": {
"url": "https://billing.stripe.com/p/session/test_12345"
}
}
]
}

Provider Notes

  • Stripe and Mollie use the same endpoint shape.
  • items[0].nextAction.url is the URL your app should open for the tenant.
  • The provider customer is created when the tenant does not already have one.

Error Responses

HTTP StatusExample Error
401{"errors":[{"validation":"error","code":"[E4010]","message":"Unauthorized Token or API key"}]}
401{"errors":[{"validation":"error","code":"[E4011]","message":"Unauthorized API key type"}]}
403{"errors":[{"validation":"error","code":"[E4030]","message":"App Is Disabled"}]}
400{"errors":[{"validation":"error","code":"[E4000]","message":"Bad Request / validation error"}]}
500{"errors":[{"validation":"error","code":"[E0000]","message":"Internal Server Error"}]}

Example

const url = `https://api.userdocks.local:5000/api/v1/apps/appUuid-value/tenants/tenantUuid-value/payment-providers/stripe/billing-portals`;

const response = await fetch(url, {
method: 'POST',
headers: {
'x-api-key': '<api-key>',
'x-client-id': 'appUuid-value',
'x-api-key-type': 'write',
'Content-Type': 'application/json',
},
body: '{"defaultReturnUrl":"https://app.example.com/account"}',
});
const data = await response.json();
console.log(response.status, data);