> ## Documentation Index
> Fetch the complete documentation index at: https://docs.prava.space/llms.txt
> Use this file to discover all available pages before exploring further.

# Enroll Card

> Provision a card only, or run the complete card-and-passkey enrollment flow without creating a payment.

Register a card for a merchant-scoped customer without creating an order, transaction, mandate, cryptogram, or payment credential.

`POST /v1/sessions/enroll-card` · Authenticated with your secret key.

> [!NOTE]
>
> This endpoint has two deliberately different contracts. `provision_only` is a synchronous,
> server-to-server operation. `full_enrollment` creates an interactive session that the cardholder
> completes on Prava's secure surface.

## Choose the request shape

| Goal | `enrollment_mode` | `vault_ref_id` | Cardholder UI | Response | Poll status |
| - | - | - | - | - | - |
| Provision an already-vaulted card | Omit or `provision_only` | Required | None | `card_id` | No |
| Full enrollment with card entry | `full_enrollment` | Omit | Embedded or hosted | Session artifacts | Yes |
| Full enrollment with an already-vaulted card | `full_enrollment` | Include | Embedded or hosted passkey flow | Session artifacts | Yes |

> [!WARNING]
>
> Do not send iframe-only fields with `provision_only`. The request schemas are strict:
> `integration_type` and `callback_url` are accepted only with `full_enrollment`, and unknown
> fields return `400 VAL_2001`.

## Request examples by use case

Choose the example that matches both where the card comes from and how Prava's secure surface
should open.

```bash Provision only theme={null}
curl -X POST https://sandbox.api.prava.space/v1/sessions/enroll-card \
  -H "Authorization: Bearer sk_test_..." \
  -H "Content-Type: application/json" \
  -d '{
    "user_id": "customer_123",
    "user_email": "customer@example.com",
    "vault_ref_id": "0b92f9d9-16ca-4a8e-ae75-2a4061cda90c",
    "consent_id": "consent_123"
  }'
```

```bash Embedded + card entry theme={null}
curl -X POST https://sandbox.api.prava.space/v1/sessions/enroll-card \
  -H "Authorization: Bearer sk_test_..." \
  -H "Content-Type: application/json" \
  -d '{
    "enrollment_mode": "full_enrollment",
    "user_id": "customer_123",
    "user_email": "customer@example.com",
    "integration_type": "embedding",
    "consent_id": "consent_123"
  }'
```

```bash Embedded + vault reference theme={null}
curl -X POST https://sandbox.api.prava.space/v1/sessions/enroll-card \
  -H "Authorization: Bearer sk_test_..." \
  -H "Content-Type: application/json" \
  -d '{
    "enrollment_mode": "full_enrollment",
    "user_id": "customer_123",
    "user_email": "customer@example.com",
    "vault_ref_id": "0b92f9d9-16ca-4a8e-ae75-2a4061cda90c",
    "integration_type": "embedding",
    "consent_id": "consent_123"
  }'
```

```bash Hosted + card entry theme={null}
curl -X POST https://sandbox.api.prava.space/v1/sessions/enroll-card \
  -H "Authorization: Bearer sk_test_..." \
  -H "Content-Type: application/json" \
  -d '{
    "enrollment_mode": "full_enrollment",
    "user_id": "customer_123",
    "user_email": "customer@example.com",
    "integration_type": "full_checkout",
    "callback_url": "https://merchant.example/card-setup/complete",
    "consent_id": "consent_123"
  }'
```

```bash Hosted + vault reference theme={null}
curl -X POST https://sandbox.api.prava.space/v1/sessions/enroll-card \
  -H "Authorization: Bearer sk_test_..." \
  -H "Content-Type: application/json" \
  -d '{
    "enrollment_mode": "full_enrollment",
    "user_id": "customer_123",
    "user_email": "customer@example.com",
    "vault_ref_id": "0b92f9d9-16ca-4a8e-ae75-2a4061cda90c",
    "integration_type": "full_checkout",
    "callback_url": "https://merchant.example/card-setup/complete",
    "consent_id": "consent_123"
  }'
```

```json Provision-only response theme={null}
{
  "card_id": "card_123"
}
```

```json Full-enrollment response theme={null}
{
  "session_id": "ses_123",
  "session_token": "eyJhbGciOi...",
  "expires_at": "2026-09-05T12:30:00.000Z",
  "iframe_url": "https://sandbox.collect.prava.space/?session=ses_123"
}
```

## Body

### Common fields

**user\_id** `string` *required*

Your stable identifier for this customer. It is scoped to the merchant account authenticated by
your secret key. Must be non-blank and no longer than 255 characters.

**user\_email** `string`

Customer email, maximum 320 characters. It is optional only when Prava already has an email for
this merchant's `user_id`; otherwise the request returns `400 ENROLL_USER_EMAIL_REQUIRED`.

**consent\_id** `string`

Optional reference to the consent record in your system, maximum 255 characters. When present it
must be non-blank and contain no control characters. Prava records whether this reference was
supplied; it does not independently validate the underlying consent.

**enrollment\_mode** `string` (default: provision\_only)

`provision_only` or `full_enrollment`. Omitting the field preserves the existing
`provision_only` behavior.

### Mode-specific fields

**vault\_ref\_id** `string`

Skyflow record UUID created using your configured card-collection credentials. Required for
`provision_only`. Optional for `full_enrollment`: include it to skip card entry, or omit it to
let the cardholder enter a card in Prava's iframe.

**integration\_type** `string` (default: full\_checkout)

Full enrollment only. Use `embedding` to mount the secure surface inside your application, or
`full_checkout` to open the Prava-hosted flow.

**callback\_url** `string`

Full enrollment only. Optional HTTPS URL, maximum 2048 characters. In hosted mode Prava redirects
the cardholder here after completion. If omitted, the final screen remains visible and tells the
cardholder they may safely close it.

## Provision only

Use this mode when you already have a valid `vault_ref_id` and only need the card provisioned.
The call completes synchronously and returns the merchant-scoped card identifier.

Do not call the enrollment-status endpoint for this mode. The `201` response is the result.

## Full enrollment

Full enrollment makes the card and passkey ready for later use. It creates an orderless session and
returns the same client artifacts used by other Prava interactive surfaces:

**session\_id** `string`

Identifier used when polling enrollment status.

**session\_token** `string`

Short-lived token passed to the SDK for iframe authentication.

**expires\_at** `string`

ISO 8601 expiry. Treat this returned value as authoritative.

**iframe\_url** `string`

Secure Prava URL. Pass or open it exactly as returned.

There is no `order_id`, transaction identifier, payment token, dynamic CVV, or cryptogram in this
response.

> [tab] Card entry in Prava
>
> Omit `vault_ref_id`. The cardholder enters the card on Prava's secure surface, then completes
> passkey setup or verifies an existing passkey.
>
> ```json theme={null}
> {
>   "enrollment_mode": "full_enrollment",
>   "user_id": "customer_123",
>   "user_email": "customer@example.com",
>   "integration_type": "embedding",
>   "consent_id": "consent_123"
> }
> ```

> [tab] Existing vault reference
>
> Include `vault_ref_id`. Card entry is skipped, but the interactive surface still opens so the
> cardholder can complete passkey setup or verification.
>
> ```json theme={null}
> {
>   "enrollment_mode": "full_enrollment",
>   "user_id": "customer_123",
>   "user_email": "customer@example.com",
>   "vault_ref_id": "0b92f9d9-16ca-4a8e-ae75-2a4061cda90c",
>   "integration_type": "full_checkout",
>   "callback_url": "https://merchant.example/card-setup/complete"
> }
> ```

## Integration types

> [tab] Embedded
>
> Set `integration_type: "embedding"`, return the session artifacts from your backend to your
> frontend, and mount the returned `iframe_url` using the SDK.
>
> ```typescript theme={null}
> import { PravaSDK } from '@prava-sdk/core';
>
> const prava = new PravaSDK({ publishableKey: 'pk_test_...' });
>
> void prava.collectPAN({
>   sessionToken: session.session_token,
>   iframeUrl: session.iframe_url,
>   container: '#card-setup',
>
>   // Card provisioning completed. Full enrollment may still be in progress.
>   onSuccess: (card) => console.log(card.enrollmentId),
>
>   // Card provisioning and passkey readiness are both complete.
>   onEnrollmentComplete: (result) => {
>     console.log(result.card_id, result.passkey);
>   },
>
>   onEnrollmentCancelled: ({ card_id }) => {
>     console.log('Enrollment cancelled', card_id);
>   },
>
>   onError: (error) => console.error(error.code, error.message),
> });
> ```
>
> Keep the SDK mounted after `onSuccess`. For a full-enrollment session, completion is signaled by
> `onEnrollmentComplete`, and your backend should confirm it through
> [Get Card Enrollment Status](https://docs.prava.space/api-reference/get-card-enrollment-status.md).

> [tab] Hosted
>
> Use `full_checkout` (the default) and redirect or open the returned URL. No frontend SDK is
> required.
>
> ```javascript theme={null}
> window.location.href = session.iframe_url;
> ```
>
> With `callback_url`, Prava redirects after completion. Without one, Prava keeps the completion
> result visible and tells the cardholder they can safely close the window. In both cases your
> backend determines the result by polling the status endpoint.

## Complete integration sequence

**1. Create the session on your backend**

Call this endpoint with your secret key. Never expose the secret key in browser code.

**2. Open Prava's secure surface**

Embed or navigate to `iframe_url`. Pass it exactly as returned; it already contains the
`session_id`.

**3. Poll from your backend**

Poll `GET /v1/sessions/{sessionId}/status`. Do not send your secret key from the browser.

**4. Accept the terminal result**

Enrollment succeeded only when `status` is `completed` and `outcome` is
`fully_enrolled`.

> [!NOTE]
>
> Retries happen inside the same iframe. If the status response contains
> `error.retryable: true`, do not create a new session and do not call a retry endpoint. Keep the
> current iframe available while the cardholder selects **Try again**; Prava reuses the already
> selected or provisioned card.

## Error responses

| Status | Code | Cause | Recovery |
| - | - | - | - |
| 400 | `VAL_2001` | Missing, incompatible, unknown, or invalid request field | Correct the request using the mode rules above |
| 400 | `ENROLL_USER_EMAIL_REQUIRED` | No email was supplied or previously stored for this `user_id` | Supply `user_email` |
| 400 | `BIN_COUNTRY_NOT_ALLOWED` / `BIN_ISSUER_NOT_ALLOWED` | Card is not eligible for provisioning | Ask the cardholder for another eligible card |
| 401 | `AUTH_1001` / `AUTH_1002` | Missing or invalid secret key | Use the correct environment's secret key |
| 429 | Rate limited | Too many enrollment requests | Back off before retrying |
| 500 | `MERCHANT_LOOKUP_ERROR` / `CONFIG_ERROR` | Merchant configuration could not be resolved | Contact support with the `X-Response-ID` |

Full-enrollment failures that occur after the session is created are returned through the status
resource, not by changing this create response.

Every response includes an `X-Response-ID` header. Include it when contacting
[support@prava.space](mailto:support@prava.space).


## OpenAPI

````yaml api-reference/openapi.json POST /v1/sessions/enroll-card
openapi: 3.1.0
info:
  title: Prava Payments API
  description: >-
    Server-side REST API for Prava Payments. All requests are authenticated with
    your secret key (sk_test_* in sandbox, sk_live_* in production).
  version: 1.0.0
servers:
  - url: https://sandbox.api.prava.space
    description: Sandbox
  - url: https://api.prava.space
    description: Production
security:
  - bearerAuth: []
paths:
  /v1/sessions/enroll-card:
    post:
      summary: Enroll Card
      description: >-
        Provision an already-vaulted card synchronously, or create an
        interactive card-and-passkey enrollment session. Neither mode creates a
        payment, order, transaction, mandate, cryptogram, or payment credential.
      operationId: enrollCard
      requestBody:
        required: true
        content:
          application/json:
            schema:
              oneOf:
                - $ref: '#/components/schemas/MerchantProvisionOnlyEnrollCardRequest'
                - $ref: '#/components/schemas/MerchantFullEnrollCardRequest'
      responses:
        '201':
          description: Card provisioned or full-enrollment session created
          headers:
            X-Response-ID:
              $ref: '#/components/headers/XResponseId'
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: >-
                      #/components/schemas/MerchantProvisionOnlyEnrollCardResponse
                  - $ref: '#/components/schemas/MerchantFullEnrollCardResponse'
        '400':
          $ref: '#/components/responses/Error'
        '401':
          $ref: '#/components/responses/Error'
        '429':
          $ref: '#/components/responses/Error'
        '500':
          $ref: '#/components/responses/Error'
components:
  schemas:
    MerchantProvisionOnlyEnrollCardRequest:
      title: Provision only
      type: object
      additionalProperties: false
      required:
        - user_id
        - vault_ref_id
      properties:
        user_id:
          type: string
          minLength: 1
          maxLength: 255
          description: The merchant's stable identifier for this customer.
        user_email:
          type: string
          format: email
          maxLength: 320
          description: >-
            Required when Prava does not already have an email for this
            merchant-scoped user.
        consent_id:
          type: string
          minLength: 1
          maxLength: 255
          description: Optional reference to the merchant's consent record.
        enrollment_mode:
          type: string
          enum:
            - provision_only
          default: provision_only
          description: May be omitted to preserve the existing synchronous behavior.
        vault_ref_id:
          type: string
          format: uuid
          description: Skyflow record UUID for the card to provision.
    MerchantFullEnrollCardRequest:
      title: Full enrollment
      type: object
      additionalProperties: false
      required:
        - enrollment_mode
        - user_id
      properties:
        user_id:
          type: string
          minLength: 1
          maxLength: 255
          description: The merchant's stable identifier for this customer.
        user_email:
          type: string
          format: email
          maxLength: 320
          description: >-
            Required when Prava does not already have an email for this
            merchant-scoped user.
        consent_id:
          type: string
          minLength: 1
          maxLength: 255
          description: Optional reference to the merchant's consent record.
        enrollment_mode:
          type: string
          enum:
            - full_enrollment
        vault_ref_id:
          type: string
          format: uuid
          description: >-
            Optional existing Skyflow record UUID. Omit it to collect the card
            in Prava's secure surface.
        integration_type:
          type: string
          enum:
            - embedding
            - full_checkout
          default: full_checkout
          description: Whether to embed Prava's secure surface or open the hosted flow.
        callback_url:
          type: string
          format: uri
          pattern: ^https://
          maxLength: 2048
          description: Optional HTTPS completion URL for the hosted flow.
    MerchantProvisionOnlyEnrollCardResponse:
      title: Provision only
      type: object
      additionalProperties: false
      required:
        - card_id
      properties:
        card_id:
          type: string
          description: Merchant-scoped identifier for the provisioned card.
    MerchantFullEnrollCardResponse:
      title: Full enrollment
      type: object
      additionalProperties: false
      required:
        - session_id
        - session_token
        - expires_at
        - iframe_url
      properties:
        session_id:
          type: string
          description: Identifier used to poll card-enrollment status.
        session_token:
          type: string
          description: Short-lived iframe authentication token.
        expires_at:
          type: string
          format: date-time
          description: Expiry of the enrollment session.
        iframe_url:
          type: string
          format: uri
          description: Prava secure-surface URL to embed or open.
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Machine-readable error code (e.g. VAL_2001, AUTH_1001)
            message:
              type: string
              description: Human-readable error message
            details:
              type: object
              description: >-
                Optional — included for validation errors to specify which
                fields failed
  headers:
    XResponseId:
      description: >-
        UUID correlation identifier for this response. Include it when
        contacting Prava support.
      schema:
        type: string
        format: uuid
  responses:
    Error:
      description: Error response
      headers:
        X-Response-ID:
          $ref: '#/components/headers/XResponseId'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'Your secret key: sk_test_* (sandbox) or sk_live_* (production).'

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.