# Token

## Create token checkout session

> Starts a new token checkout session for the payment.\
> \
> Further processing continues according to the underlying payment method stored in the token, e.g. card session flow.\
> \
> This endpoint is available for both customer-initiated and merchant-initiated payments.<br>

```json
{"openapi":"3.1.0","info":{"title":"E-commerce Gateway API","version":"1.0.0"},"servers":[{"url":"https://sandbox-api.ecomm.api.tietoevry.com"}],"security":[{"OAuth2ClientAuthentication":[]}],"components":{"securitySchemes":{"OAuth2ClientAuthentication":{"type":"openIdConnect","description":"This API uses OAuth 2 with the client credentials flow. [More info](https://www.rfc-editor.org/rfc/rfc6749#section-4.4)","openIdConnectUrl":"https://ecomm.api.tietoevry.com/auth/realms/participants-tietoevry/protocol/openid-connect/token"}},"schemas":{"CreateTokenCheckoutSessionSchema":{"type":"object","properties":{"gatewayTokenId":{"type":"string","description":"Unique ID of the token to use for the payment","maxLength":64}},"required":["gatewayTokenId"],"title":"Create token checkout session request"},"CheckoutSessionInformationResponse":{"type":"object","properties":{"action":{"oneOf":[{"$ref":"#/components/schemas/AuthenticateWith3DSAction"},{"$ref":"#/components/schemas/RedirectToShopAction"},{"$ref":"#/components/schemas/ShowChallengeAction"}]},"sessionId":{"type":"string","description":"Unique ID of the checkout session","maxLength":64},"sessionStatus":{"type":"string","description":"Status of the checkout session","enum":["INITIALIZED","WAITING_AUTHENTICATION","WAITING_CHALLENGE","WAITING_PRE_SCA","WAITING_SCA","WAITING_CONFIRMATION","SENT_FOR_PROCESSING","FAILED","COMPLETED"],"title":"Checkout session status"}}},"AuthenticateWith3DSAction":{"allOf":[{"$ref":"#/components/schemas/CardAction"},{"type":"object","properties":{"_links":{"$ref":"#/components/schemas/AuthenticateWith3DSAction.Links"},"type":{"type":"string","enum":["AUTHENTICATE_WITH_3DS"]}}}]},"CardAction":{"discriminator":{"propertyName":"type"},"properties":{"type":{"type":"string"}},"required":["type"]},"AuthenticateWith3DSAction.Links":{"type":"object","properties":{"checkoutRedirect":{"$ref":"#/components/schemas/Link"},"threeDsMethod":{"$ref":"#/components/schemas/Link"}}},"Link":{"type":"object","properties":{"href":{"type":"string"}}},"RedirectToShopAction":{"allOf":[{"$ref":"#/components/schemas/CardAction"},{"type":"object","properties":{"_links":{"$ref":"#/components/schemas/RedirectToShopAction.Links"},"type":{"type":"string","enum":["REDIRECT_TO_SHOP"]}}}]},"RedirectToShopAction.Links":{"type":"object","properties":{"shopRedirect":{"$ref":"#/components/schemas/Link"}}},"ShowChallengeAction":{"allOf":[{"$ref":"#/components/schemas/CardAction"},{"type":"object","properties":{"challengeHtml":{"type":"string","description":"3DS challenge HTML content"},"type":{"type":"string","enum":["SHOW_CHALLENGE"]}}}]},"ErrorResponse":{"type":"object","properties":{"apiClientMessages":{"type":"array","items":{"$ref":"#/components/schemas/ApiClientMessage"}}}},"ApiClientMessage":{"type":"object","properties":{"category":{"type":"string","enum":["ERROR"]},"code":{"type":"string"},"text":{"type":"string"}}}}},"paths":{"/egw/{version}/payments/{paymentId}/sessions/token":{"post":{"description":"Starts a new token checkout session for the payment.\n\nFurther processing continues according to the underlying payment method stored in the token, e.g. card session flow.\n\nThis endpoint is available for both customer-initiated and merchant-initiated payments.\n","operationId":"createTokenCheckoutSession","parameters":[{"description":"ID of the request, unique to the call, as determined by the initiating party","in":"header","name":"X-Request-Id","required":true,"schema":{"type":"string","format":"uuid","description":"ID of the request, unique to the call, as determined by the initiating party"}},{"description":"Unique ID of the payment","in":"path","name":"paymentId","required":true,"schema":{"type":"string","description":"Unique ID of the payment","maxLength":64}},{"in":"path","name":"version","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateTokenCheckoutSessionSchema"}}},"required":true},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CheckoutSessionInformationResponse"}}},"description":"OK"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"Bad Request"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"Forbidden"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"Not Found"},"409":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"Conflict"},"503":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}},"description":"Service Unavailable"}},"summary":"Create token checkout session","tags":["Token Session API"]}}}}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.ecomm.api.tietoevry.com/documentation-es/referencias-de-la-api/api-para-comerciantes/pagos/sesiones/token.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
