# Link a support request to a GitHub issue

`POST /api/v1/admin/support-requests/{supportRequest}/issue-links`

Link a request to a GitHub issue or pull request it waits on, so the team knows whom to write back to when it ships. A request can wait on several. The status does not change, and the person who asked does not see the link.

Only an administrator of this instance can use these endpoints, and only with an API key that carries the administration scope by name. Anybody else, including an administrator whose key does not carry it, gets 404 as though the endpoint did not exist.

Monica keeps the reference only and never asks GitHub anything about the issue.

## Parameters

- `supportRequest` (uuid, required): The id of the request, of any account on the instance.
- `reference` (string, required): The issue as owner/repository#number, or its address on GitHub (an issues or a pull address). Anything else answers 422 with “Write the issue as owner/repository#number, or paste its address on GitHub.”, and an issue the request is already linked to, whatever its letter case, answers 422 with “This issue is already linked to this request.”

## Returns

The link that was written.

- `data` (object): The linked issue.
- `data.type` (string): Always support_issue_link.
- `data.id` (string): The id of the link, to unlink it.
- `data.attributes` (object): Everything the link holds.
- `data.attributes.reference` (string): The issue as GitHub writes it, owner/repository#number.
- `data.attributes.url` (string): The address of the issue on GitHub. GitHub sends an issue number that is a pull request on to the pull request.
- `data.attributes.linked_by` (string): The name of the administrator who linked it.
- `data.attributes.linked_at` (timestamp): When it was linked, as a count of seconds since 1970.

## Rate limit

Sixty requests per minute, per user, shared by every key and device. Every answer carries the budget left in `X-RateLimit-Remaining`.

## Request

```sh
curl https://my.monicahq.com/api/v1/admin/support-requests/7c1e4a92-5b3d-4f08-a6e1-93d2c8b05f17/issue-links \
  -X POST \
  -H "Authorization: Bearer $MONICA_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
      "reference": "monicahq/monica#1287"
  }'
```

```javascript
const response = await fetch('https://my.monicahq.com/api/v1/admin/support-requests/7c1e4a92-5b3d-4f08-a6e1-93d2c8b05f17/issue-links', {
  method: 'POST',
  headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    reference: 'monicahq/monica#1287',
  }),
})
const data = await response.json()
```

```php
$response = Http::withToken($token)->post('https://my.monicahq.com/api/v1/admin/support-requests/7c1e4a92-5b3d-4f08-a6e1-93d2c8b05f17/issue-links', [
    'reference' => 'monicahq/monica#1287',
]);
```

## Response

`201`

```json
{
    "data": {
        "type": "support_issue_link",
        "id": "4d2b9e71-8c3a-4f56-a0e7-61f5c9b28d03",
        "attributes": {
            "reference": "monicahq/monica#1287",
            "url": "https://github.com/monicahq/monica/issues/1287",
            "linked_by": "Jim Halpert",
            "linked_at": 1791551700
        }
    }
}
```
