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

# CVC Sessions

# CVC Sessions

CVC sessions temporarily store CVV/CVC data separately from the card token.

## Overview

CVV/CVC codes are:

* **Never stored** with the card token
* **Stored temporarily** in a separate session
* **Deleted after use** (for security)
* **Required by most PSPs** for card-not-present transactions

## Session Lifecycle

```mermaid theme={null}
flowchart LR
  A["Tokenize\nwith CVV"] --> B["Session\nCreated"]
  B -->|"Proxy used"| C["Proxy\nUsed"]
  C --> D["Deleted"]
  B -->|"90 sec TTL\n(1 year for test tokens)"| E["Expired"]
```

## Creating a CVC Session

CVC sessions are created automatically when you tokenize with a CVV:

```bash theme={null}
curl -X POST $YOUR_VAULT_URL/tokenize \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY" \
  -d '{
    "type": "card",
    "data": {
      "cardNumber": "4111111111111111",
      "expirationMonth": "12",
      "expirationYear": "2025",
      "cvv": "123"
    }
  }'
```

**Response:**

```json theme={null}
{
  "success": true,
  "token": "tok_a1b2c3d4e5f6",
  "cvc_session_id": "550e8400-e29b-41d4-a716-446655440000"
}
```

## Session Properties

| Property | Regular Token | Test Token |
| - | - | - |
| TTL | 90 seconds | 1 year (test tokens) |
| Deleted after use | Yes | No |
| Can be reused | No | Yes |

## Using a CVC Session

Include `cvc_session_id` in proxy requests:

```json theme={null}
{
  "token": "tok_a1b2c3d4e5f6",
  "cvc_session_id": "550e8400-e29b-41d4-a716-446655440000",
  "proxy_url": "https://api.stripe.com/v1/charges",
  "request_data": {
    "card": {
      "number": "${cardNumber}",
      "cvc": "${cvv}"  // Replaced from CVC session
    }
  }
}
```

## Session Expiration

### Regular Sessions (90 seconds)

```json theme={null}
{
  "success": false,
  "message": "CVC session expired or not found"
}
```

**Solution:** Re-tokenize with CVV to get a new session.

### Test Sessions (1 year)

Test token CVC sessions last much longer for development convenience.

## Without CVC Session

If you don't have a CVC session:

### Option 1: Skip CVV

Some PSPs allow transactions without CVV:

```json theme={null}
{
  "token": "tok_a1b2c3d4e5f6",
  "proxy_url": "https://api.psp.com/charge",
  "request_data": {
    "card": {
      "number": "${cardNumber}",
      "exp_month": "${expirationMonth}",
      "exp_year": "${expirationYear}"
      // No CVV
    }
  }
}
```

### Option 2: Re-tokenize

Collect CVV again and create a new session:

```bash theme={null}
curl -X POST $YOUR_VAULT_URL/tokenize \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY" \
  -d '{
    "type": "card",
    "data": {
      "cardNumber": "4111111111111111",
      "expirationMonth": "12",
      "expirationYear": "2025",
      "cvv": "123"
    }
  }'
```

With deduplication enabled, you'll get the same token with a new CVC session.

## Error Responses

### Session Not Found

```json theme={null}
{
  "success": false,
  "message": "CVC session expired or not found"
}
```

**Causes:**

* Session expired (>90 seconds)
* Session already used
* Invalid session ID
* Session from different project

### Missing Session ID

Using `${cvv}` placeholder without a CVC session:

```json theme={null}
{
  "success": false,
  "message": "CVC session required for CVV placeholder"
}
```

## Best Practices

### 1. Use CVC Sessions Promptly

The 90-second window is intentional for security. Design your flow to:

1. Tokenize with CVV
2. Immediately process payment
3. Don't store session IDs long-term

### 2. Handle Expiration Gracefully

```javascript theme={null}
try {
  await processPayment(token, cvcSessionId);
} catch (error) {
  if (error.message.includes('CVC session expired')) {
    // Prompt user to re-enter CVV
    const newSession = await retokenizeWithCVV();
    await processPayment(token, newSession.cvc_session_id);
  }
}
```

### 3. Use Test Tokens for Development

Test tokens have 1-year CVC sessions, making development easier:

```bash theme={null}
curl -X POST $YOUR_VAULT_URL/test-tokens \
  -H "Content-Type: application/json" \
  -H "X-API-Key: YOUR_API_KEY" \
  -d '{
    "type": "card",
    "data": {
      "cardNumber": "4111111111111111",
      "expirationMonth": "12",
      "expirationYear": "2025",
      "cvv": "123"
    }
  }'
```

### 4. Delete a session when needed

You can delete a CVC session by ID (e.g. after a successful transaction) with **DELETE /proxy/delete-cvc-session/{session_id}** (API key auth). See [API Reference → Proxy](https://docs.ozura.com/api-reference/vault/proxy-transaction.md#delete-cvc-session).

### 5. Don't Store CVC Session IDs

CVC session IDs are temporary. Store only:

* ✅ Token (`tok_xxx`)
* ✅ Masked card number
* ❌ CVC session ID (temporary)
* ❌ CVV (never store)

## Flow Diagrams

### Standard Payment Flow

```mermaid theme={null}
sequenceDiagram
  participant User
  participant App as Your App
  participant Vault as Ozura Vault
  participant PSP

  User->>App: Enter card + CVV
  App->>Vault: POST /tokenize
  Vault-->>App: token + cvc_session_id
  App->>Vault: POST /proxy/transaction
  Vault->>PSP: Forward with card data
  PSP-->>Vault: Response
  Vault-->>App: Proxy response
  Note over Vault: CVC session deleted
  App-->>User: Payment result
```

### Recurring Payment Flow

```mermaid theme={null}
sequenceDiagram
  participant App as Your App
  participant Vault as Ozura Vault
  participant PSP

  Note over App: Stored token, no CVV
  App->>Vault: POST /proxy/transaction<br/>(no cvc_session_id)
  Vault->>PSP: Forward (no CVV)
  PSP-->>Vault: Response
  Vault-->>App: Proxy response
```

## Next Steps

* [Tokenization](../tokenization/README.md) - Creating tokens with CVV
* [Test Tokens](../tokenization/test-tokens.md) - Long-lived CVC sessions
* [JSON Proxy](https://docs.ozura.com/guides/vault/proxy/json.md) - Using proxy requests


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