> ## 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.

# Network Tokenize from Existing Token

> Create a network token from an existing PCI Booking card token.

Network-tokenizes a card that is already stored as a PCI Booking token. The card data is retrieved from the existing token, submitted to the card network, and the resulting network token is stored as a new PCI Booking token.

Optionally, the original token can be deleted after successful network tokenization by setting `deleteExisting=true`.

## Error Responses

| Code    | HTTP Status | Condition                                                 |
| ------- | ----------- | --------------------------------------------------------- |
| `-1003` | `401`       | API key is missing or invalid.                            |
| `-1003` | `401`       | Authenticated user does not own the specified card token. |
| `-160`  | `404`       | The `cardUri` does not resolve to a valid stored card.    |
| `-125`  | `400`       | Request body validation failed.                           |
| `-150`  | `500`       | Network tokenization failed.                              |

## Parameters

### Headers

<ParamField header="Authorization" type="string" required>
  Your API key prefixed with `APIKEY`. Example: `APIKEY your-api-key`. See the [Authentication guide](/getting-started/authentication).
</ParamField>

### Query String

<ParamField query="cardUri" type="string" required>
  The full URI of the existing PCI Booking token to network-tokenize (e.g. `https://service.pcibooking.net/api/payments/paycard/tok_abc123`).
</ParamField>

<ParamField query="deleteExisting" type="boolean" default="false">
  When `true`, the original PCI Booking token is deleted after successful network tokenization.
</ParamField>

<ParamField query="loc" type="string">
  Token storage region for the new network token. One of: `US`, `IN`, `AU`, `JP`, `CA`, `IE`, `GB`, `BR`. If omitted, uses the account default.
</ParamField>

### Request Body

The request body contains the same `TokenizationRequest` fields as [Network Tokenize a Card](/api-reference/additional/network-tokenize-card), excluding the `Card` object (since card data comes from the existing token).

<ParamField body="ConsumerLanguage" type="string" default="en">
  ISO 639-1 language code (exactly 2 characters).
</ParamField>

<ParamField body="CardHolder" type="object">
  Cardholder details required by the card network. See [Network Tokenize a Card](/api-reference/additional/network-tokenize-card) for the full field reference.
</ParamField>

<ParamField body="DeviceScore" type="integer" default="5">
  Device trust score (1-5).
</ParamField>

<ParamField body="AccountScore" type="integer" default="5">
  Account trust score (1-5).
</ParamField>

<ParamField body="DeviceLocationLat" type="number">
  Device latitude (-90 to 90).
</ParamField>

<ParamField body="DeviceLocationLon" type="number">
  Device longitude (-180 to 180).
</ParamField>

<ParamField body="DeviceIpAddress" type="string">
  Device IP address.
</ParamField>

<ParamField body="CardSource" type="string">
  Source of the card data.
</ParamField>

<RequestExample>
  ```javascript Node.js theme={null}
  const params = new URLSearchParams({
    cardUri: 'https://service.pcibooking.net/api/payments/paycard/tok_abc123',
    deleteExisting: 'false',
    loc: 'IE'
  });

  const response = await fetch(`https://service.pcibooking.net/api/networkToken/token?${params}`, {
    method: 'POST',
    headers: {
      'Authorization': 'APIKEY your-api-key',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      ConsumerLanguage: 'en',
      CardHolder: {
        FirstName: 'John',
        LastName: 'Doe',
        Email: 'john.doe@example.com',
        ClientIPAddress: '203.0.113.42',
        CountryCode: 'US'
      },
      DeviceScore: 5,
      AccountScore: 5
    })
  });

  const data = await response.json();
  console.log(data);
  ```

  ```python Python theme={null}
  import requests

  response = requests.post(
      'https://service.pcibooking.net/api/networkToken/token',
      headers={
          'Authorization': 'APIKEY your-api-key',
          'Content-Type': 'application/json'
      },
      params={
          'cardUri': 'https://service.pcibooking.net/api/payments/paycard/tok_abc123',
          'deleteExisting': 'false',
          'loc': 'IE'
      },
      json={
          'ConsumerLanguage': 'en',
          'CardHolder': {
              'FirstName': 'John',
              'LastName': 'Doe',
              'Email': 'john.doe@example.com',
              'ClientIPAddress': '203.0.113.42',
              'CountryCode': 'US'
          },
          'DeviceScore': 5,
          'AccountScore': 5
      }
  )

  print(response.json())
  ```
</RequestExample>

## Response

**201** - Network token created. The `Location` header contains the new PCI Booking token URI. If `deleteExisting=true` was set, the original token is deleted.

<ResponseExample>
  ```json 201 theme={null}
  {
      "ResultCode": "Success",
      "Brand": "MasterCard",
      "TokenId": "5412750012003478",
      "TokenizedCard": {
          "Number": "541275******3478",
          "ExpirationMonth": 6,
          "ExpirationYear": 2029
      }
  }
  ```

  ```json 404 theme={null}
  {
      "code": -160,
      "message": "Resource not found",
      "moreInfo": "Invalid Card Uri value",
      "errorList": null
  }
  ```

  ```json 401 theme={null}
  {
      "code": -1003,
      "message": "Not authorized to access this resource",
      "moreInfo": "User is not the owner of this bank card",
      "errorList": null
  }
  ```
</ResponseExample>
