# Configure a Custom Hostname for a Subscription Bot Project

> Configure a custom hostname for a Discord or Telegram subscription bot project.

Source: https://docs.botsubscription.com/api/settings/custom-hostname/

Set the custom hostname for a <strong>Discord subscription bot</strong> or <strong>Telegram subscription bot</strong> project. Features that use `custom_hostname` explain their own hostname requirements in their respective API documentation.

<ApiEndpoint method="PATCH" endpoint="/v2/projects/{project_id}/settings/custom_hostname" />

<ApiAuthorization type="Bearer API Key" />

**API key access:** Unrestricted project API key required. Restricted keys cannot call this endpoint.

<ApiSection title="Path Parameters">
  <ApiParameter name="project_id" type="string" required description="The unique identifier of the project." />
</ApiSection>

<ApiSection title="Request Body">
  <ApiParameter name="value" type="string" required description="One exact, bare hostname. Wildcards are not supported. Do not include a scheme, port, path, query, or trailing slash." />
</ApiSection>

The value represents exactly one hostname. Setting `example.com` does not include `www.example.com`, `subdomain.example.com`, or any other subdomain. Configure the exact hostname required by the feature using this setting.

Valid:

```text
example.com
```

Invalid:

```text
https://example.com/
example.com/path
*.example.com
```

This request only sets the project's `custom_hostname` value. It does not configure CORS, DNS, API hosting, or browser access. If the value conflicts with an existing verified hostname or origin, the API returns a conflict and does not assign it to the project.

<ApiSamplePane>

<ApiRequestSample title="Request">

```bash
curl -X PATCH "https://api.botsubscription.com/v2/projects/YOUR_PROJECT_ID/settings/custom_hostname" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "value": "example.com"
  }'
```

```javascript
const projectId = 'YOUR_PROJECT_ID';
const response = await fetch(`https://api.botsubscription.com/v2/projects/${projectId}/settings/custom_hostname`, {
  method: 'PATCH',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({ value: 'example.com' })
});
// 204 No Content on success
```

```python
import requests

project_id = 'YOUR_PROJECT_ID'
response = requests.patch(
    f'https://api.botsubscription.com/v2/projects/{project_id}/settings/custom_hostname',
    headers={
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
    },
    json={'value': 'example.com'}
)
# 204 No Content on success
```

```php
$project_id = 'YOUR_PROJECT_ID';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.botsubscription.com/v2/projects/{$project_id}/settings/custom_hostname");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer YOUR_API_KEY',
    'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
    'value' => 'example.com'
]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
// 204 No Content on success
```

</ApiRequestSample>

<ApiResponseTabs>
  <ApiResponse status={204} description="Custom hostname updated">

No response body is returned on success.

  </ApiResponse>
  <ApiResponse status={409} description="Hostname conflict">

```json
{
  "ok": false,
  "request_id": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
  "method": "PATCH",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/settings/custom_hostname",
  "code": 409,
  "error": {
    "error_code": "CONFLICT",
    "message": "This hostname is already in use by another project."
  }
}
```

  </ApiResponse>
  <ApiResponse status={403} description="Restricted API key rejected">

```json
{
  "ok": false,
  "request_id": "44444444-4444-4444-8444-444444444444",
  "method": "PATCH",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/settings/custom_hostname",
  "code": 403,
  "error": {
    "error_code": "FORBIDDEN",
    "message": "API key does not have the required scope for this endpoint."
  }
}
```

  </ApiResponse>
  <ApiResponse status={422} description="Invalid custom hostname">

```json
{
  "ok": false,
  "request_id": "44444444-4444-4444-8444-444444444444",
  "method": "PATCH",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/settings/custom_hostname",
  "code": 422,
  "error": {
    "message": "Invalid custom hostname.",
    "error_code": "VALIDATION_ERROR"
  }
}
```

  </ApiResponse>
  <ApiResponse status={401} description="Invalid or expired API key">

```json
{
  "ok": false,
  "request_id": "44444444-4444-4444-8444-444444444444",
  "method": "PATCH",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/settings/custom_hostname",
  "code": 401,
  "error": {
    "message": "Invalid or expired authentication token.",
    "error_code": "UNAUTHORIZED"
  }
}
```

  </ApiResponse>
</ApiResponseTabs>

</ApiSamplePane>
