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

# Store Paycard (Card Migration)

> Store card details in PCI Booking when migrating from local storage. The card data is sent in XML format.

> [card] [Card Migration Guide](https://developers.pcibooking.net/capture-cards/store-card-migration.md)
>
> Migrate existing card data into PCI Booking tokens

Use this endpoint to migrate card data you currently store on your own systems into PCI Booking tokens. Send the full card details in XML format, and PCI Booking returns a token URI you can use for all future operations. This is typically a one-time bulk migration step when onboarding with PCI Booking.

> [!WARNING]
>
> **Sending raw card data through this endpoint puts your system in PCI DSS scope**, since it requires handling raw card numbers to call it. This endpoint is intended for a one-time migration from a system that is already PCI DSS compliant - it is not recommended as an ongoing capture method for production traffic. Use a [card capture method](https://developers.pcibooking.net/capture-cards/overview.md) that keeps card data off your systems instead. See [Card Migration](https://developers.pcibooking.net/capture-cards/store-card-migration.md) for the full guidance.

> [!WARNING]
>
> This endpoint accepts card details in **XML format only**. Set `Content-Type: text/xml`.

## Error Responses

| Code | HTTP Status | Condition |
| - | - | - |
| -123 | 400 | Request body is not valid XML or is null |
| -123 | 400 | XML fails schema validation |
| -160 | 404 | Submitted data is PaymentInfo instead of BankCard |
| -179 | 400 | Card validation failed (Luhn check, expiration, or CVV). Returns `errorList` with details |
| -125 | 400 | Card storage failed due to invalid data |
| -150 | 500 | Card storage failed due to a system error |
| none | 401 | Authentication failed. The response body is empty. See [Authentication and Permission Failures](https://developers.pcibooking.net/reference/error-handling.md#authentication-and-permission-failures) |
| -1003 | 403 | Missing `CanTokenize` permission. `message` names the reason |

### Error detail

Each condition below gives the exact `moreInfo` text, why it happens and how to resolve it. The full set is on the [Error Handling](https://developers.pcibooking.net/reference/error-handling.md) page.

> [accordion] -123 Message badly formatted - body is not valid XML for this endpoint
>
> **HTTP status:** `400`
>
> **`message`:** `Message badly formatted`
>
> **`moreInfo`:**
>
> ```text theme={null}
> Bad XML document
> Bad XML document. Errors: <validation errors>
> ```
>
> **Reason.** The endpoint expects XML that validates against its schema, and the body either did not parse as XML or failed validation. When validation is the cause, the failing details are listed in `moreInfo`.
>
> **How to resolve.**
>
> 1. Read the list in `moreInfo`. It names the elements that failed, which is usually enough on its own.
> 2. Check element order. The schema is sequence-sensitive, so correctly named elements in the wrong order still fail.
> 3. Check the declared encoding matches what you actually sent.
>
> **See also:** [Card Data XML Structure](https://developers.pcibooking.net/reference/card-data-xml-structure.md)

> [accordion] -125 Bad input data - expiration date rejected
>
> **HTTP status:** `400`
>
> **`message`:** `Bad input data`
>
> **`moreInfo`:**
>
> ```text theme={null}
> Expiration year/month error
> ```
>
> **Reason.** The expiration month or year is missing, out of range, or in a format the endpoint does not accept.
>
> **How to resolve.**
>
> 1. Send the month as two digits, `01` through `12`.
> 2. Check the year format the endpoint expects. Some accept two digits and some four, and they are not interchangeable.
> 3. Check the date is not in the past. An expired card is rejected at tokenization.
>
> **See also:** [Card Validation Errors](https://developers.pcibooking.net/reference/card-validation-errors.md)

> [accordion] -179 Bad input parameter - CVV format rejected
>
> **HTTP status:** `400`
>
> **`message`:** `Bad input parameter`
>
> **`moreInfo`:**
>
> ```text theme={null}
> Invalid CVV value: <value>
> ```
>
> **Reason.** The CVV was present but did not match three or four digits. The API applies the same rule to every card brand.
>
> **How to resolve.**
>
> 1. Send three or four digits, digits only, with no spaces or punctuation. The API accepts either length for any brand - it does not require four digits for American Express, and it does not reject four digits on other brands.
>
> 2. Omit the field entirely rather than sending an empty string. An absent or empty CVV is accepted, and the card is simply stored without one.
>
> > [!NOTE]
> >
> > The [hosted card entry form](https://developers.pcibooking.net/capture-cards/hosted-card-entry-form.md) is stricter than the API. Where it has detected the brand it accepts exactly three digits for every brand except American Express, which takes three or four; where the brand is unknown it accepts three or four. A CVV that the form rejects would therefore have been accepted had you sent it to the API directly.

> [accordion] 401 with an empty body - authentication failed
>
> **HTTP status:** `401`
>
> **Response body:** empty. There is no `code`, `message` or `moreInfo`.
>
> **Reason.** PCI Booking could not identify the caller. The response is the same for every cause:
>
> * The `Authorization` header (or the `x-pcibooking-api-key` header) is missing, badly formatted, or has no `APIKEY` keyword.
> * The API key is not valid, or it belongs to the other environment (sandbox or production).
> * The `sessionToken` is not valid or has expired.
> * The `accessToken` is not valid, has expired, has an expiration time further ahead than the maximum allowed, or was already used. An access token works once only, so reloading a page that uses it, such as a card display iframe, also returns this response.
>
> **How to resolve.**
>
> 1. Confirm the `APIKEY` prefix is present and there is a single space between it and the key.
> 2. Confirm the key belongs to the same environment as the host you called. Sandbox and production keys are not interchangeable.
> 3. If you use a session token, check it has not expired and start a new session if it has.
> 4. If you use an access token, generate a new one for every request, including every reload of an iframe.
> 5. Check that your HTTP client does not drop the `Authorization` header on a redirect. Most clients remove it after a 301 or 302.
>
> **See also:** [Authentication](https://developers.pcibooking.net/getting-started/authentication.md), [Authentication and Permission Failures](https://developers.pcibooking.net/reference/error-handling.md#authentication-and-permission-failures)

## Parameter Constraints

| Parameter | Type | Required | Constraints |
| - | - | - | - |
| validateLuhn | boolean | No | Defaults to `true`. Validates card number with Luhn algorithm |
| validateExpiration | boolean | No | Defaults to `false`. When `true`, rejects expired cards |
| saveCVV | boolean | No | Defaults to `false`. Requires CVV retention policy to be set after storage |
| eliminateCardDuplication | boolean | No | Defaults to `false`. When `true`, returns existing token if card already stored (same card number + expiration date) |
| Content-Type | string | Yes | Must be `text/xml` |
| Auth | string | Yes | ApiKey, AccessToken, or SessionToken |

The request body must contain a `BankCardDetails` XML document. See [Card Data XML Structure](https://developers.pcibooking.net/reference/card-data-xml-structure.md) for the full field reference.

```xml theme={null}
<BankCardDetails xmlns="http://www.pcibooking.net/reservation" schemaVersion="1.0">
  <BankCard>
    <Type>Visa</Type>
    <Number>4918914107195005</Number>
    <NameOnCard>Juan Dela Cruz</NameOnCard>
    <ExpirationDate>
      <Month>07</Month>
      <Year>2020</Year>
    </ExpirationDate>
    <IssueNumber>2</IssueNumber>
    <OwnerID>123456789</OwnerID>
    <CVV>123</CVV>
  </BankCard>
</BankCardDetails>
```

On success, a card token is created and the token URI is returned in the `Location` response header. The response body contains the submitted card details with sensitive data masked.

## Parameters

### Authentication

**API key, access token or session token.** Use the API key for server-to-server calls, and an access token or a session token when the call is made from a browser. Send one of the three.

**Authorization** `string`

Your API key prefixed with `APIKEY`. Example: `APIKEY your-api-key`. The `x-pcibooking-api-key` header is also accepted. See the [Authentication guide](https://developers.pcibooking.net/getting-started/authentication.md).

**accessToken** `string`

Generated on your side. Single use, and valid for up to 72 hours. [How to generate](https://developers.pcibooking.net/getting-started/authentication.md#access-token).

**sessionToken** `string`

Returned by an API call. Valid for 5 minutes, and can be used more than once within that time. [How to generate](https://developers.pcibooking.net/api-reference/general/start-temporary-session.md).

### Headers

**Content-Type** `string` *required* (default: text/xml)

Must be `text/xml`. This endpoint accepts card details in XML format only.

### Query String

**ref** `string`

A reference value that can be used to query for this card token.

**merchant** `string`

User ID of the property to associate the token with. Found under "Property settings" in the user's site. Property Management only. Property Management is closed to new accounts; see [Property Management](https://developers.pcibooking.net/additional-functions/property-management).

**allowedUserId** `string`

User ID of the PCI Booking customer (booker ID) to associate the token with. The customer must share their PCI Booking user ID with you.

**saveCVV** `boolean` (default: false)

Whether to save the CVV in the database. **true** - save the CVV. **false** - do not save the CVV.

**eliminateCardDuplication** `boolean` (default: false)

When `true`, PCI Booking checks whether this card already exists as a token in your account (same card number + expiration date) and returns the existing token instead of creating a new one.

**ValidateExpiration** `boolean` (default: false)

Whether to check if the expiration date is valid. `True` validates the expiration date and tokenization will fail if expired. `False` accepts the date as is, even if in the past.

**validateLuhn** `boolean` (default: true)

Whether to check if the card number passes the Luhn algorithm. `True` validates using Luhn and tokenization will fail if the number does not pass. `False` accepts the number as is.

**loc** `string`

The region where the card data is stored. One of: `US`, `IN`, `AU`, `JP`, `CA`, `IE`, `GB`, `BR`. If omitted, your account's default region is used, or Ireland if your account has no default. See [Card Storage Regions](https://developers.pcibooking.net/concepts/tokenization-explained.md#card-storage-regions).

### Request Body

**BankCardDetails** `object`

The BankCardDetails object. See the XML structure and example above.

## Request Example

Store a Visa card and associate it with a reference and property:

> [tab] curl
>
> ```bash theme={null}
> curl -X POST "https://service.pcibooking.net/api/payments/paycard?ref=booking-12345&merchant=hotel-sunrise&saveCVV=true" \
>   -H "Authorization: APIKEY your-api-key" \
>   -H "Content-Type: text/xml" \
>   -d '<?xml version="1.0" encoding="utf-8"?>
> <BankCardDetails xmlns="http://www.pcibooking.net/reservation" schemaVersion="1.0">
>   <BankCard>
>     <Type>Visa</Type>
>     <Number>4111111111111111</Number>
>     <NameOnCard>Jane Smith</NameOnCard>
>     <ExpirationDate>
>       <Month>12</Month>
>       <Year>2028</Year>
>     </ExpirationDate>
>     <CVV>123</CVV>
>   </BankCard>
> </BankCardDetails>'
> ```

> [tab] Node.js
>
> ```javascript theme={null}
> const xmlBody = `<?xml version="1.0" encoding="utf-8"?>
> <BankCardDetails xmlns="http://www.pcibooking.net/reservation" schemaVersion="1.0">
>   <BankCard>
>     <Type>Visa</Type>
>     <Number>4111111111111111</Number>
>     <NameOnCard>Jane Smith</NameOnCard>
>     <ExpirationDate>
>       <Month>12</Month>
>       <Year>2028</Year>
>     </ExpirationDate>
>     <CVV>123</CVV>
>   </BankCard>
> </BankCardDetails>`;
>
> const params = new URLSearchParams({
>   ref: "booking-12345",
>   merchant: "hotel-sunrise",
>   saveCVV: "true"
> });
>
> const response = await fetch(
>   `https://service.pcibooking.net/api/payments/paycard?${params}`,
>   {
>     method: "POST",
>     headers: {
>       "Authorization": "APIKEY your-api-key",
>       "Content-Type": "text/xml"
>     },
>     body: xmlBody
>   }
> );
>
> const tokenUri = response.headers.get("Location");
> console.log("Token URI:", tokenUri);
>
> const data = await response.json();
> console.log(data);
> ```

> [tab] Python
>
> ```python theme={null}
> import requests
>
> xml_body = """<?xml version="1.0" encoding="utf-8"?>
> <BankCardDetails xmlns="http://www.pcibooking.net/reservation" schemaVersion="1.0">
>   <BankCard>
>     <Type>Visa</Type>
>     <Number>4111111111111111</Number>
>     <NameOnCard>Jane Smith</NameOnCard>
>     <ExpirationDate>
>       <Month>12</Month>
>       <Year>2028</Year>
>     </ExpirationDate>
>     <CVV>123</CVV>
>   </BankCard>
> </BankCardDetails>"""
>
> response = requests.post(
>     "https://service.pcibooking.net/api/payments/paycard",
>     params={
>         "ref": "booking-12345",
>         "merchant": "hotel-sunrise",
>         "saveCVV": "true"
>     },
>     headers={
>         "Authorization": "APIKEY your-api-key",
>         "Content-Type": "text/xml"
>     },
>     data=xml_body
> )
>
> token_uri = response.headers.get("Location")
> print("Token URI:", token_uri)
> print(response.json())
> ```

On success, the token URI is returned in the `Location` response header (e.g. `Location: https://service.pcibooking.net/api/payments/paycard/555fd7b49f134b42a5dbe4d576b2e527`).

## Response

**201** - Card stored. A `Location` header is returned with the token URI. The response body contains the card details with sensitive data masked.

> [!NOTE]
>
> Remember to set the [CVV Retention Policy](https://developers.pcibooking.net/capture-cards/cvv-retention-policy.md) on the token if you stored the CVV.

```json 201 theme={null}
{
    "Type": "Visa",
    "Number": "491891******5005",
    "NameOnCard": "Juan Dela Cruz",
    "ExpirationDate": {
        "Month": "07",
        "Year": "2020"
    },
    "IssueNumber": "2"
}
```

```text 401 theme={null}
Empty response body.
Authentication failed: the API key, session token or access token is missing or was not accepted.
See "Authentication and Permission Failures" on the Error Handling page.
```

```json Unauthorized (no access) 401 theme={null}
{
    "code": -1003,
    "message": "You are not authorized to access this resource. Please contact customer support.",
    "moreInfo": "Merchant or Owner are not associated with bank card [{{Token}] userID: SoBookIt",
    "errorList": null
}
```


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