> Markdown version of https://docs.paynow.gg/management-api/customer-portal-sessions/. The index of all pages is at https://docs.paynow.gg/llms.txt, and any page can be read as Markdown by appending `.md` to its URL.

# Customer Portal Sessions

## Create a customer portal session

> Creates a customer portal session from a secure server using an API Key.
> The returned session contains the token and URL to hand to the customer.

```json
{"openapi":"3.1.1","info":{"title":"PayNow Management API","version":"v1"},"tags":[{"name":"customer_portal_sessions"}],"security":[{"APIKey":[]}],"components":{"securitySchemes":{"APIKey":{"type":"apiKey","description":"An API Key token generated in the Dashboard in the format 'APIKey TOKEN_HERE'.","name":"Authorization","in":"header","x-gitbook-prefix":"APIKey","x-gitbook-token-placeholder":"TOKEN_HERE"}},"schemas":{"FlakeId":{"type":"string","additionalProperties":false,"format":"flake-id","example":"411486491630370816"},"CreateCustomerPortalSessionRequestDto":{"required":["flow"],"type":"object","properties":{"flow":{"$ref":"#/components/schemas/CustomerPortalSessionFlowDto"},"expires_in":{"$ref":"#/components/schemas/Period"},"return_url":{"type":["null","string"],"description":"URL to redirect the customer back to after completing the portal flow"}},"additionalProperties":false,"description":"Request to create a new customer portal session from your back-end server using the management API"},"CustomerPortalSessionFlowDto":{"type":"object","properties":{"subscription_cancel":{"$ref":"#/components/schemas/SubscriptionCancelFlowDto"},"subscription_payment_method_update":{"$ref":"#/components/schemas/SubscriptionPaymentMethodUpdateFlowDto"}},"additionalProperties":false,"description":"The flow a customer portal session is scoped to. At most one of the flows is set."},"SubscriptionCancelFlowDto":{"required":["subscription_id"],"type":"object","properties":{"subscription_id":{"$ref":"#/components/schemas/FlakeId"}},"additionalProperties":false,"description":"Portal flow for cancelling a specific subscription"},"SubscriptionPaymentMethodUpdateFlowDto":{"required":["subscription_id"],"type":"object","properties":{"subscription_id":{"$ref":"#/components/schemas/FlakeId"}},"additionalProperties":false,"description":"Portal flow for updating the payment method of a specific subscription"},"Period":{"type":"string","additionalProperties":false,"description":"ISO 8601 duration format","format":"period","example":"P1Y2M3DT4H5M6S"},"CustomerPortalSessionDto":{"required":["created_at","customer_id","expires_at","id","store_id"],"type":"object","properties":{"id":{"$ref":"#/components/schemas/FlakeId"},"store_id":{"$ref":"#/components/schemas/FlakeId"},"customer_id":{"$ref":"#/components/schemas/FlakeId"},"flow":{"$ref":"#/components/schemas/CustomerPortalSessionFlowDto"},"token":{"type":["null","string"],"description":"The token used to access the portal session"},"url":{"type":["null","string"],"description":"The URL to redirect the customer to for this portal session"},"return_url":{"type":["null","string"],"description":"URL to redirect the customer back to after completing the portal flow"},"created_at":{"type":"string","description":"Date and time when the portal session was created","format":"date-time"},"expires_at":{"type":"string","description":"Date and time when the portal session expires","format":"date-time"}},"additionalProperties":false,"description":"Represents a customer portal session"},"PayNowError":{"required":["code","message","status"],"type":"object","properties":{"status":{"type":"integer","description":"The HTTP status code.","format":"int32","example":400},"code":{"type":"string","description":"The PayNow parseable error code.","example":"bad-request"},"message":{"type":"string","description":"The human-readable error message.","example":"Bad Request Example"},"trace_id":{"type":["null","string"],"description":"A distributed trace ID used for debugging.","example":"234a5bcd543ef3fa53ce929d0e0e4736"},"errors":{"type":["null","array"],"items":{"$ref":"#/components/schemas/ValidationError"},"description":"An array of multiple errors. Only used by some API services."}},"additionalProperties":false,"description":"Represents a PayNow error"},"ValidationError":{"required":["code","message","path","validation"],"type":"object","properties":{"code":{"type":"string","description":"The parseable error code."},"message":{"type":"string","description":"The human-readable error message."},"path":{"type":"string","description":"The path leading to the validation error."},"validation":{"type":"string","description":"Type of the validation that failed."}},"additionalProperties":false,"description":"A validation error."}}},"paths":{"/v1/stores/{storeId}/customers/{customerId}/portal-sessions":{"post":{"tags":["customer_portal_sessions"],"summary":"Create a customer portal session","description":"Creates a customer portal session from a secure server using an API Key.\nThe returned session contains the token and URL to hand to the customer.","operationId":"CustomersPortalSessions_CreateCustomerPortalSession","parameters":[{"name":"storeId","in":"path","description":"The ID of the store to create the portal session for.","required":true,"schema":{"$ref":"#/components/schemas/FlakeId"}},{"name":"customerId","in":"path","description":"The ID of the customer to create the portal session for.","required":true,"schema":{"$ref":"#/components/schemas/FlakeId"}}],"requestBody":{"description":"The portal session data.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateCustomerPortalSessionRequestDto"}},"text/json":{"schema":{"$ref":"#/components/schemas/CreateCustomerPortalSessionRequestDto"}},"application/*+json":{"schema":{"$ref":"#/components/schemas/CreateCustomerPortalSessionRequestDto"}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerPortalSessionDto"}}}},"default":{"description":"Error response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PayNowError"}}}}},"security":[{"APIKey":[]}]}}}}
```

