# Manage Request Attachment — Jira Service Desk

> Adds, replaces, or deletes a single attachment on a customer request (ticket) that already exists. To attach file(s) while creating a brand-new request, use Create Request's attachments prop instead — use this tool only for requests that…

- Key: `jira_service_desk-manage-request-attachment`
- Type: Action (Write)
- Version: 0.0.2
- App: Jira Service Desk (`jira_service_desk`) — https://pipedream.com/apps/jira-service-desk.md
- This page (HTML): https://pipedream.com/apps/jira-service-desk/actions/manage-request-attachment
- Hints: destructive · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/jira_service_desk/actions/manage-request-attachment/manage-request-attachment.mjs

## Description

Adds, replaces, or deletes a single attachment on a customer request (ticket) that already exists. To attach file(s) while creating a brand-new request, use **Create Request**'s `attachments` prop instead — use this tool only for requests that already exist. Set `operation` to `add` to attach a new file, `update` to replace an existing attachment with a different file (there's no in-place replace in the API, so this uploads the new file and only deletes the old one once the new one is confirmed attached), or `delete` to remove an attachment. `add` and `update` require `serviceDeskId` (the temp-file upload step is scoped by service desk, not by issue) — use **List Service Desks** to find it, or read it off the response of the request that created the ticket. `update` and `delete` require `attachmentId`, the numeric ID of the attachment being replaced or removed; the `add`/`update` response doesn't expose this as a plain field, so use **List Issue Attachments** on the same request to look it up. Worked example: to replace an attachment `10050` on request `HD-12` with a new file, call with Operation `update`, Issue ID Or Key `HD-12`, Service Desk ID `1`, Attachment ID `10050`, and File `/tmp/revised-report.pdf`. For `update`, if the new file attaches successfully but removing the old attachment then fails, the response includes a `deleteError` string alongside the successful attachment data — the request ends up with both files rather than losing either one, and the error is never masked as a full failure. By default the attachment is visible to the customer who raised the request (`public: true`); set `public` to `false` to attach an internal-only file. [See the documentation](https://developer.atlassian.com/cloud/jira/service-desk/rest/api-group-request/#api-rest-servicedeskapi-request-issueidorkey-attachment-post)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `cloudId` | `string` | Yes | The Atlassian site (cloud) ID, e.g. 822faf0d-5427-420e-9016-999d3dc76918. Run List Sites to get the id of every site you can access. |
| `operation` | `string` | Yes | Whether to add a new attachment, replace (update) an existing one, or delete one. |
| `issueIdOrKey` | `string` | Yes | The ID or key of the Jira Service Desk request (e.g. IT-42 or 10001). Use List My Requests to find the issueKey of a request (in its requests array). |
| `serviceDeskId` | `string` | No | Required for add and update. The service desk the request belongs to. Use List Service Desks to find valid IDs (e.g. 1). |
| `file` | `string` | No | Required for add and update. The file to attach, as a file URL or a path to a file in the /tmp directory (e.g. /tmp/myFile.pdf). |
| `attachmentId` | `string` | No | Required for update and delete. The numeric ID of the attachment being replaced or removed, e.g. 10050. The add/update response doesn't expose this as a plain field — the ID is only embedded in a _links.jiraRest URL nested under attachments.values[]. Use List Issue Attachments instead, which extracts the ID for you. |
| `public` | `boolean` | No | Whether the attached file is visible to the customer who raised the request. Defaults to true; set to false to attach an internal-only file. Only applies to add and update. |
| `syncDir` | `dir` | No | SyncDir |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "jira_service_desk",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "jira_service_desk-manage-request-attachment",
  arguments: {
    cloudId: "Cloud ID",
    operation: "Operation",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "jira_service_desk-manage-request-attachment",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    jira_service_desk: { authProvisionId: "apn_xxxxxxx" },
    cloudId: "Cloud ID",
    operation: "Operation",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "jira_service_desk-manage-request-attachment",
    "configured_props": {
      "jira_service_desk": { "authProvisionId": "apn_xxxxxxx" },
      "cloudId": "Cloud ID",
      "operation": "Operation"
    }
  }'
```

---

- App: https://pipedream.com/apps/jira-service-desk.md · All apps: https://pipedream.com/apps
