Create Credential Session

Creates a credential vault session for a merchant and returns a secure iframe URL. Embed the returned URL in your web application so the customer can securely store their credentials for the given merchant.

Recent Requests
Log in to see full request history
TimeStatusUser Agent
Retrieving recent requests…
LoadingLoading…

Creates a secure, short-lived Credential Vault session for a merchant and returns a hosted URL. Embed the URL in your web application (or share it as a link) so the customer can store their merchant login securely — the credentials never pass through your backend.

How it Works

Some merchants require the customer to be logged in before an order can be placed. Calling POST /credentials/session provisions a time-limited vault session tied to a specific customer email and merchant pair. The flow is:

  1. Your backend calls this endpoint with the merchant's domain and the customer's email.
  2. CartAI returns an iframeUrl and an expiresIn value (in minutes).
  3. You embed the URL in an iframe or send it to the customer or admin as a link.
  4. They enter their merchant login on CartAI's hosted page. The credentials are stored in the vault against the email and merchant pair.
  5. When you create a checkout task for the same email and merchant with options.useSavedCredentialToLogin set to true, CartAI's agent uses the saved credentials to sign in during checkout.
⚠️

Never expose your API key in client-side code. Always call this endpoint from your backend and pass only the resulting iframeUrl to your frontend.


Authentication

Every request must include your API key in the request header.

x-api-key: YOUR_API_KEY_HERE

To get your API key, generate it from the CartAI Admin Portal after your account is provisioned. Contact the CartAI Account Management Team to request access.


Request Body

FieldTypeRequiredDescription
merchantDomainstring✅ YesWebsite URL of the merchant the credentials belong to (e.g. "https://saltiebeauty.com").
emailstring (email format)✅ YesThe customer's email address. Credentials are stored against this email, so use the same one at checkout.

Full Request Example

curl --location 'https://api.cartai.ai/credentials/session' \
  --header 'x-api-key: YOUR_API_KEY_HERE' \
  --header 'Content-Type: application/json' \
  --data-raw '{
      "merchantDomain": "https://saltiebeauty.com",
      "email": "[email protected]"
  }'

Response

A successful request returns HTTP 200 with the following body.

{
  "status": "success",
  "message": "Credential vault session created successfully",
  "data": {
    "iframeUrl": "https://credshield.cartai.ai?token=<jwt_token>&merchant=saltiebeauty.com",
    "expiresIn": 10
  }
}

Response Fields

FieldTypeDescription
statusstring"success" when the session was created.
messagestringHuman-readable result message.
data.iframeUrlstringSecure credential vault URL. Embed it as an iframe in your web application or share it as a link.
data.expiresInintegerHow long the session stays valid, in minutes.
⚠️

The session expires after expiresIn minutes. Create the session when you are ready to show it to the user, not ahead of time. If it expires, simply create a new one.


Embedding the Vault URL

The iframeUrl is designed to be embedded directly in your web application so the user stays on your page while they enter their credentials.

<iframe
  id="credential-frame"
  src="IFRAME_URL"
  width="480"
  height="640"
  style="border: none;"
  title="CartAI Credential Vault"
></iframe>
// Dynamically set the src after creating the session
document.getElementById('credential-frame').src = sessionData.data.iframeUrl;

Alternatively, send the URL by email, chat, or your admin console so the user can open it directly — for example, when an admin is setting up a shared business account rather than a shopper saving their own login.

💡

Tip: The URL contains a session token. Treat it like a one-time link — deliver it only to the person who owns the merchant account.


Using the Saved Credentials at Checkout

Once the user has saved their credentials, create a checkout task with options.useSavedCredentialToLogin set to true, the same email in customer.contact.email, and a product URL on the same merchant domain. CartAI looks up the credentials saved for that email and merchant pair and uses them to log in during checkout.

If the email or merchant domain doesn't match, CartAI can't find the saved credentials. See the Credential Vault guide for the full end-to-end flow.


Error Reference

HTTP StatusCauseWhat to do
200Session created successfullyUse the returned iframeUrl to collect the customer's credentials
400Missing or invalid fields in the request bodyCheck that merchantDomain and email are both present and well-formed
401Missing or invalid x-api-keyVerify the header name and that you are using the correct environment key
429Rate limitedBack off and retry after a delay
5xxCartAI server errorRetry with exponential backoff; contact support if it persists
Body Params
string
required

Merchant website URL the credentials belong to

string
required

Customer's email address

Headers
string
required
Responses

400

Bad Request

Language
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json