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

# Add or update CSS

> Create a new CSS record or update an existing one by replacing its content.

<Card title="Stylesheets Guide" icon="book" href="/account-setup/stylesheets">
  Customize the appearance of hosted forms
</Card>

Creates a new CSS stylesheet resource or replaces an existing one. Use this to customize the look and feel of PCI Booking's hosted card entry and card display forms to match your brand.

## Error Responses

| HTTP Status | Error Code | Description                                                                                                                           |
| ----------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------- |
| 400         |            | Missing required fields. One or more required properties (`ContentLTR`, `ContentRTL`, `IsDefault`) are missing from the request body. |
| 400         |            | No CSS content. Both `ContentLTR` and `ContentRTL` are empty. At least one must contain valid CSS.                                    |
| 400         |            | Invalid CSS syntax. The provided CSS content could not be parsed. The response includes the line number and error details.            |
| 401         | -1003      | Not authenticated. The API key is missing or invalid.                                                                                 |
| 403         | -1003      | Not authorized. The API key does not have the `CanConfigureSettings` permission.                                                      |
| 500         |            | Internal server error. The resource could not be saved.                                                                               |

## Parameter Constraints

| Parameter      | Constraint                                                                                           |
| -------------- | ---------------------------------------------------------------------------------------------------- |
| `ResourceName` | Required. Must contain only alphanumeric characters (`[a-zA-Z0-9]+`).                                |
| `ContentLTR`   | Required (may be empty string). At least one of `ContentLTR` or `ContentRTL` must contain valid CSS. |
| `ContentRTL`   | Required (may be empty string). At least one of `ContentLTR` or `ContentRTL` must contain valid CSS. |

<Info title="Same method is used for creating a new CSS resource and updating an existing CSS resource">
  Please be aware that the same method is used for both creating a new CSS and updating an existing one.
  If you update an existing CSS, the content of it will be replaced with the uploaded content and this action **cannot be undone**.
</Info>

## 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="ResourceName" type="string" required>
  The resource name to assign to this CSS record.
</ParamField>

### Request Body

<ParamField body="Description" type="string" required>
  Description of this CSS resource, displayed in the user's site.
</ParamField>

<ParamField body="ContentLTR" type="string" required>
  Stylesheet configuration for LTR content. At least one of `ContentLTR` or `ContentRTL` must contain valid CSS.
</ParamField>

<ParamField body="ContentRTL" type="string" required>
  Stylesheet configuration for RTL content. At least one of `ContentLTR` or `ContentRTL` must contain valid CSS. Typically left blank unless you use RTL pages.
</ParamField>

<ParamField body="IsDefault" type="boolean" required>
  Sets this CSS resource as the default CSS for your account.
</ParamField>

<RequestExample>
  ```javascript Node.js theme={null}
  const response = await fetch('https://service.pcibooking.net/api/resources/stylesheet/BrandCSS', {
    method: 'PUT',
    headers: {
      'Authorization': 'APIKEY your-api-key',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      Description: 'Brand-specific card form styles',
      ContentLTR: 'body { background-color: #f5f5f5; } h1 { color: #333; }',
      ContentRTL: '',
      IsDefault: false
    })
  });

  console.log(response.status); // 201 created, 200 updated
  ```

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

  response = requests.put(
      'https://service.pcibooking.net/api/resources/stylesheet/BrandCSS',
      headers={
          'Authorization': 'APIKEY your-api-key',
          'Content-Type': 'application/json'
      },
      json={
          'Description': 'Brand-specific card form styles',
          'ContentLTR': 'body { background-color: #f5f5f5; } h1 { color: #333; }',
          'ContentRTL': '',
          'IsDefault': False
      }
  )

  print(response.status_code)  # 201 created, 200 updated
  ```
</RequestExample>

## Response

<ResponseExample>
  ```json 201 theme={null}
  // Empty body. Returned when a new CSS resource is created (the ResourceName did not exist before).
  ```

  ```json 200 theme={null}
  // Empty body. Returned when an existing CSS resource is updated (the ResourceName already existed).
  ```

  ```json 400 Missing required fields theme={null}
  {
      "Message": "The request is invalid.",
      "ModelState": {
          "model": [
              "Required property 'IsDefault' not found in JSON. Path '', line 6, position 1."
          ],
          "model.ContentLTR": [
              "The ContentLTR field is required."
          ]
      }
  }
  ```

  ```json 400 No CSS content provided theme={null}
  {
      "Message": "The request is invalid.",
      "ModelState": {
          "ContentError": [
              "At least one of the fields, ContentLTR or ContentRTL, must have valid CSS content"
          ]
      }
  }
  ```

  ```json 400 Invalid CSS syntax theme={null}
  {
      "Message": "Invalid CSS: Line number: 1<br />Error: invalid selector after \n"
  }
  ```

  ```json 401 theme={null}
  {
      "code": -1003,
      "message": "Not authorized to access this resource",
      "moreInfo": "Bad or missing authorization data, expected APIKEY",
      "errorList": null
  }
  ```
</ResponseExample>
