> ## 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 Payment Gateway Credentials

> Store credentials for a payment gateway.

<Card title="Gateway Credentials Guide" icon="book" href="/account-setup/gateway-credentials">
  Store and manage payment gateway credentials
</Card>

<Warning title="Using the same ID would overwrite stored credentials">
  If you try to store credentials with an ID that already exists in your user in PCI Booking, the new set of credentials will overwrite the stored ones.
  This cannot be undone.
</Warning>

## Error Responses

| Code    | HTTP Status | Condition                                                                        |
| ------- | ----------- | -------------------------------------------------------------------------------- |
| `-1003` | `401`       | API key is missing or invalid, or user type is not `Booker`.                     |
| `-125`  | `400`       | Request body could not be parsed as JSON.                                        |
| `-125`  | `400`       | Request body is missing the `paymentGateway` (or `virtualCardProvider`) section. |
| `-125`  | `400`       | The `Name` property is missing from the provider section.                        |
| `-125`  | `400`       | The specified payment gateway name is not valid.                                 |
| `-125`  | `400`       | No credentials were provided, but the gateway requires them.                     |
| `-125`  | `400`       | One or more credential field names do not match the gateway's expected fields.   |

## Parameter Constraints

* **credentialsId**: Required string. Used as the unique identifier for this credential set.
* **Request body**: Must be valid JSON containing either a `paymentGateway` or `virtualCardProvider` top-level key.
* **Name** (inside provider object): Required, non-empty string matching a supported gateway.
* **Credentials** (inside provider object): All property names must match the gateway's expected credential field names (see [Retrieve Credential Structure](/api-reference/process-cards/retrieve-credential-structure)).

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

### Path Parameters

<ParamField path="credentialsId" type="string" required>
  The unique ID for this set of credentials. You will reference this ID when sending a [request through the Universal Payment Gateway](/api-reference/process-cards/process-transaction).
</ParamField>

### Request Body

<ParamField body="PaymentGateway" type="object">
  A custom object specifying the name of the payment gateway and its credentials.
</ParamField>

<RequestExample>
  ```javascript Node.js theme={null}
  const response = await fetch(
    'https://service.pcibooking.net/api/credentials/my-stripe-credentials',
    {
      method: 'PUT',
      headers: {
        'Authorization': 'APIKEY your-api-key',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify({
        paymentGateway: {
          Name: 'Stripe',
          Credentials: {
            SecretKey: 'sk_live_abc123'
          }
        }
      })
    }
  );

  console.log(response.status);
  ```

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

  response = requests.put(
      'https://service.pcibooking.net/api/credentials/my-stripe-credentials',
      headers={
          'Authorization': 'APIKEY your-api-key',
          'Content-Type': 'application/json'
      },
      json={
          'paymentGateway': {
              'Name': 'Stripe',
              'Credentials': {
                  'SecretKey': 'sk_live_abc123'
              }
          }
      }
  )

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

## Response

<ResponseExample>
  ```text 200 theme={null}
  Credentials stored successfully. No content returned.
  ```

  ```json 400 theme={null}
  {
      "code": -125,
      "message": "Bad input data",
      "moreInfo": "...",
      "errorList": null
  }
  ```
</ResponseExample>
