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.
| Time | Status | User Agent | |
|---|---|---|---|
Retrieving recent requests… | |||
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:
- Your backend calls this endpoint with the merchant's domain and the customer's email.
- CartAI returns an
iframeUrland anexpiresInvalue (in minutes). - You embed the URL in an iframe or send it to the customer or admin as a link.
- They enter their merchant login on CartAI's hosted page. The credentials are stored in the vault against the email and merchant pair.
- When you create a checkout task for the same email and merchant with
options.useSavedCredentialToLoginset totrue, 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 resultingiframeUrlto your frontend.
Authentication
Every request must include your API key in the request header.
x-api-key: YOUR_API_KEY_HERETo 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
| Field | Type | Required | Description |
|---|---|---|---|
merchantDomain | string | ✅ Yes | Website URL of the merchant the credentials belong to (e.g. "https://saltiebeauty.com"). |
email | string (email format) | ✅ Yes | The 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
| Field | Type | Description |
|---|---|---|
status | string | "success" when the session was created. |
message | string | Human-readable result message. |
data.iframeUrl | string | Secure credential vault URL. Embed it as an iframe in your web application or share it as a link. |
data.expiresIn | integer | How long the session stays valid, in minutes. |
The session expires afterexpiresInminutes. 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 Status | Cause | What to do |
|---|---|---|
200 | Session created successfully | Use the returned iframeUrl to collect the customer's credentials |
400 | Missing or invalid fields in the request body | Check that merchantDomain and email are both present and well-formed |
401 | Missing or invalid x-api-key | Verify the header name and that you are using the correct environment key |
429 | Rate limited | Back off and retry after a delay |
5xx | CartAI server error | Retry with exponential backoff; contact support if it persists |
400Bad Request