# Rename Target - Update a Target's Display Name via API

> Rename a Discord role or Telegram channel target without touching its other access settings.

Source: https://docs.botsubscription.com/api/targets/rename/

Change a target's display name on its own, without sending the rest of its configuration. Use this instead of [Update Target](https://docs.botsubscription.com/api/targets/update/) when a rename is the only change you need to make.

<ApiEndpoint method="PATCH" endpoint="/v2/projects/{project_id}/targets/{target_id}/name" />

<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." />
  <ApiParameter name="target_id" type="string" required description="The internal target ID (UUID)." />
</ApiSection>

<ApiSection title="Request Body">
  <ApiParameter name="target_name" type="string" required description="New display name for the target. 1-100 characters; leading and trailing whitespace is trimmed." />
</ApiSection>

A successful rename returns `total: 1`, a `message`, and the updated target object in `data`.

<ApiSection title="Response Metadata">
  <ApiParameter name="parent_target_id" type="string | null" description="Optional parent target UUID; null when there is no parent." />
  <ApiParameter name="participant_count" type="integer" description="Optional nonnegative participant count." />
  <ApiParameter name="origin" type="string" description="Optional target origin: manual or auto-discovered." />
  <ApiParameter name="discovered_at" type="string | null" description="Optional discovery time as a UTC ISO 8601 timestamp, or null when no discovery time is recorded." />
</ApiSection>

<ApiSamplePane>

<ApiRequestSample title="Request">

```bash
curl -X PATCH "https://api.botsubscription.com/v2/projects/YOUR_PROJECT_ID/targets/11111111-1111-1111-1111-111111111111/name" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "target_name": "VIP Members"
  }'
```

```javascript
const project_id = 'YOUR_PROJECT_ID';
const target_id = '11111111-1111-1111-1111-111111111111';
const response = await fetch(`https://api.botsubscription.com/v2/projects/${project_id}/targets/${target_id}/name`, {
  method: 'PATCH',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    target_name: 'VIP Members'
  })
});
const data = await response.json();
```

```python
import requests

project_id = 'YOUR_PROJECT_ID'
target_id = '11111111-1111-1111-1111-111111111111'
response = requests.patch(
    f'https://api.botsubscription.com/v2/projects/{project_id}/targets/{target_id}/name',
    headers={
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
    },
    json={
        'target_name': 'VIP Members'
    }
)
data = response.json()
```

```php
$project_id = 'YOUR_PROJECT_ID';
$target_id = '11111111-1111-1111-1111-111111111111';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.botsubscription.com/v2/projects/{$project_id}/targets/{$target_id}/name");
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([
    'target_name' => 'VIP Members'
]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
```

</ApiRequestSample>

<ApiResponseTabs>
  <ApiResponse status={200} description="Target renamed">

```json
{
  "ok": true,
  "request_id": "11111111-1111-1111-1111-111111111111",
  "method": "PATCH",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/targets/11111111-1111-1111-1111-111111111111/name",
  "code": 200,
  "total": 1,
  "message": "Successfully updated 1 target(s)",
  "data": {
    "target_id": "11111111-1111-1111-1111-111111111111",
    "target_name": "VIP Members",
    "platform": "discord",
    "kind": "role",
    "external_id": "123456789012345678",
    "is_enabled": true,
    "plan_count": 0,
    "parent_target_id": null,
    "participant_count": 0,
    "origin": "manual",
    "discovered_at": null
  }
}
```

  </ApiResponse>
  <ApiResponse status={404} description="Target not found">

```json
{
  "ok": false,
  "request_id": "11111111-1111-1111-1111-111111111111",
  "method": "PATCH",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/targets/11111111-1111-1111-1111-111111111111/name",
  "code": 404,
  "error": {
    "error_code": "NOT_FOUND",
    "message": "Target not found"
  }
}
```

  </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/targets/22222222-2222-4222-8222-222222222222/name",
  "code": 401,
  "error": {
    "message": "Invalid or expired authentication token.",
    "error_code": "UNAUTHORIZED"
  }
}
```

  </ApiResponse>
  <ApiResponse status={422} description="Empty target name">

```json
{
  "ok": false,
  "request_id": "44444444-4444-4444-8444-444444444444",
  "method": "PATCH",
  "path": "/v2/projects/11111111-1111-4111-8111-111111111111/targets/22222222-2222-4222-8222-222222222222/name",
  "code": 422,
  "errors": [
    {
      "message": "body.target_name: Target name must not be empty.",
      "error_code": "VALIDATION_ERROR"
    }
  ]
}
```

  </ApiResponse>
</ApiResponseTabs>

</ApiSamplePane>
