# attachDealFile

Attach a CHAT file to a deal: the write twin of listDealFiles. Pass the artifactId of a file your organization already holds: the id the chat assistant sees on its artifact shelf (`(artifactId: …) [origin] filename`). A Library item id is refused: use fileLibraryItemsOnDeal. The server resolves it to the underlying file, org-scoped, links it to dealId, and returns the file (id, fileName, fileUrl, createdAt); read it back with listDealFiles. The deal must be in a pipeline owned by or shared with your organization, and the artifact's file must belong to your organization: a foreign artifact is refused, so you cannot link another org's bytes onto a deal you own. There is no raw-bytes upload op yet (the shared upload key is not org-scoped).

- Call: `POST https://server.goliathdata.com/api/v1/call` with `{ "operationId": "attachDealFile", "variables": {...} }`
- Scope: `WRITE`
- Type: mutation
- Idempotency: honors `Idempotency-Key` (24 h)
- Rate-limited: no

## Variables

- `dealId`: `ID!` (required)
- `artifactId`: `ID!` (required)

## Response (data, an example)

```json
{
  "dealMutation": {
    "attachDealFileFromArtifact": {
      "id": "<ID>",
      "fileName": "…",
      "fileUrl": "…",
      "createdAt": "2026-01-01T00:00:00.000Z"
    }
  }
}
```

## Example

```bash
curl https://server.goliathdata.com/api/v1/call \
  -H "Authorization: Bearer $GOLIATH_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "operationId": "attachDealFile",
    "variables": {
      "dealId": "<dealId>",
      "artifactId": "<artifactId>"
    }
  }'
```
