View a markdown version of this page

CreateBillingPortalSession - AWS App Monetization

CreateBillingPortalSession

Opens the AWS App Monetization hosted customer billing portal for a user. This operation returns the billing portal URL that your application redirects the user's browser to. No state is persisted.

Request Syntax

POST /apps/appId/users/userId/billing-portal-sessions?scope=scope HTTP/1.1 Content-type: application/json { "clientToken": "string", "refreshUrl": "string", "returnUrl": "string", "sessionDurationSeconds": number }

URI Request Parameters

The request uses the following URI parameters.

appId

The ID of the app the portal is for.

Length Constraints: Minimum length of 1. Maximum length of 64.

Pattern: [A-Za-z0-9_-]+

Required: Yes

scope

Required. The environment: live or sandbox.

Valid Values: sandbox | live

Required: Yes

userId

The ID of the end user the portal is for. Do not include personally identifiable or otherwise sensitive data in this value.

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: [A-Za-z0-9_.~-]+

Required: Yes

Request Body

The request accepts the following data in JSON format.

clientToken

A unique, case-sensitive identifier to ensure that the operation completes no more than one time. If this token matches a previous request, the service ignores the request but does not return an error.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 128.

Pattern: [!-~]+

Required: No

refreshUrl

A URL in your app. A plan checkout started from the portal doesn't redirect here: if the buyer cancels, they return to the portal's plans page. Bound into the session alongside returnUrl.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 2048.

Required: Yes

returnUrl

A URL in your app. A plan checkout started from the portal doesn't redirect here: after payment, the buyer returns to the portal's My subscription page. Bound into the session and reused for every checkout the buyer launches from the portal.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 2048.

Required: Yes

sessionDurationSeconds

The lifetime of the hosted session, in seconds, counted from this call. Omit to use the service default. It does not set how long billingPortalUrl works; see expiresAt.

Type: Integer

Valid Range: Minimum value of 1. Maximum value of 86400.

Required: No

Response Syntax

HTTP/1.1 201 Content-type: application/json { "billingPortalUrl": "string", "expiresAt": number, "manageToken": "string", "sessionToken": "string" }

Response Elements

If the action is successful, the service sends back an HTTP 201 response.

The following data is returned in JSON format by the service.

billingPortalUrl

The URL of the billing portal page to redirect the end user's browser to. The URL carries a short-lived session token or a single-use link in its fragment. The link works once, until expiresAt or the end of the session if sooner.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 8192.

expiresAt

The time when the single-use link in billingPortalUrl expires, 10 minutes after it was created. After this time the URL no longer works and you must create a new session.

Type: Timestamp

manageToken

A short-lived token that authorizes updates to the buyer profile from the billing portal. Returned only with sessionToken.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 4096.

sessionToken

The billing portal session token carried in the fragment of billingPortalUrl. Absent when billingPortalUrl carries a single-use link instead.

Type: String

Length Constraints: Minimum length of 1. Maximum length of 4096.

Errors

For information about the errors that are common to all actions, see Common Error Types.

AccessDeniedException

The caller does not have sufficient permission to perform this action.

message

Human-readable description of the access-denied condition.

HTTP Status Code: 403

InternalServerException

An unexpected error occurred while processing the request.

message

Human-readable description of the server error.

retryAfterSeconds

Advice to clients on when the call can be safely retried.

HTTP Status Code: 500

ResourceNotFoundException

The referenced resource does not exist.

message

Human-readable description of the missing resource.

resourceId

Identifier of the resource that was not found.

resourceType

Type of the resource that was not found (for example, "App" or "Plan").

HTTP Status Code: 404

ThrottlingException

The request was denied due to request throttling.

message

Human-readable description of the throttling condition.

quotaCode

Service Quotas identifier for the throttled quota.

retryAfterSeconds

Advice to clients on when the call can be safely retried.

serviceCode

Service Quotas identifier for the originating service.

HTTP Status Code: 429

ValidationException

The request failed input validation.

fieldList

The specific input fields that failed validation, when applicable.

message

Human-readable description of what failed validation.

reason

Machine-readable reason the request failed validation, so callers act without parsing the message.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: