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

# Check Code Availability

> Check if a custom code is available for use before creating a link

## Request

<ParamField header="X-API-KEY" type="string" required>
  Your project API key: `b2co_your_api_key`
</ParamField>

<ParamField path="code" type="string" required>
  The custom code to check for availability (3-50 characters, alphanumeric, hyphens, and underscores only)
</ParamField>

## Response

<ResponseField name="success" type="boolean">
  Indicates if the request was successful
</ResponseField>

<ResponseField name="data" type="object">
  Code availability information
</ResponseField>

<ResponseField name="data.code" type="string">
  The code that was checked
</ResponseField>

<ResponseField name="data.available" type="boolean">
  Whether the code is available for use (true = available, false = already in use)
</ResponseField>

<ResponseField name="data.message" type="string">
  Human-readable message about the code availability
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X GET "https://api.bit2connect.com/1.0/links/check/my-custom-code" \
    -H "X-API-KEY: b2co_your_api_key"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    "https://api.bit2connect.com/1.0/links/check/my-custom-code",
    {
      headers: {
        "X-API-KEY": "b2co_your_api_key",
      },
    }
  );

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

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

  url = "https://api.bit2connect.com/1.0/links/check/my-custom-code"
  headers = {"X-API-KEY": "b2co_your_api_key"}

  response = requests.get(url, headers=headers)
  data = response.json()
  ```
</RequestExample>

<ResponseExample>
  ```json Available Code theme={null}
  {
    "success": true,
    "data": {
      "code": "my-custom-code",
      "available": true,
      "message": "Code is available for use"
    }
  }
  ```

  ```json Code Already In Use theme={null}
  {
    "success": true,
    "data": {
      "code": "summer-sale",
      "available": false,
      "message": "Code is already in use in this project"
    }
  }
  ```

  ```json Invalid Code Format theme={null}
  {
    "success": false,
    "error": {
      "code": "VALIDATION_ERROR",
      "message": "Code can only contain letters, numbers, hyphens, and underscores"
    }
  }
  ```
</ResponseExample>

## Code Requirements

<Info>
  **Code Format Rules**:

  * Length: 3-50 characters
  * Allowed characters: letters (a-z, A-Z), numbers (0-9), hyphens (-), underscores (\_)
  * Case sensitive: `MyCode` and `mycode` are different
  * Must be unique within your project
</Info>

## Error Codes

<ResponseField name="VALIDATION_ERROR" type="string">
  Invalid code format or length
</ResponseField>

<ResponseField name="INVALID_API_KEY" type="string">
  API key is missing or invalid
</ResponseField>

<ResponseField name="RATE_LIMIT_EXCEEDED" type="string">
  Too many requests, please try again later
</ResponseField>

## Usage Tips

<Tip>
  **Best Practice**: Always check code availability before attempting to create a link with a custom code. This prevents `CODE_ALREADY_EXISTS` errors during link creation.
</Tip>

Use this endpoint in your workflow:

1. Check if your desired code is available
2. If available, proceed with link creation
3. If not available, try a different code or let the system generate one automatically
