---
updatedAt: 2026-06-09T17:02:17.000Z
agentTools:
  projectIndex: https://hq.docs.netevia.com/llms.txt
---

# /api/v1/tickets/getAttachmentById

## Get Attachment by ID

Retrieves the binary content of a single ticket attachment, returned as a Base64-encoded string along with the original filename and MIME type. Use this endpoint when you need to download or display a specific document that was previously attached to a ticket.

### Endpoint

`GET /api/v1/tickets/getAttachmentById`

### Authentication

Basic HTTP Authentication required.
Encode `username:password` in Base64 and pass in the Authorization header:

```
Authorization: Basic {base64(username:password)}
```

### When to use

Use this endpoint to retrieve the actual file content of an attachment — for example, to download a voided check, processing statement, or compliance document that was uploaded to a ticket. First call `GET /api/v1/tickets/getAttachmentsByTicketId` to obtain the attachment ID, then use this endpoint to fetch the file content.

### Query Parameters

| Parameter  | Type            | Required | Description                                     |
| ---------- | --------------- | -------- | ----------------------------------------------- |
| `id`       | integer (int32) | Yes      | Merchant profile ID associated with the ticket. |
| `ticketId` | integer (int32) | Yes      | ID of the ticket the attachment belongs to.     |
| `attachId` | integer (int32) | Yes      | ID of the specific attachment to retrieve.      |

### Response

**200 OK**

| Field              | Type          | Description                                                       |
| ------------------ | ------------- | ----------------------------------------------------------------- |
| `data.content`     | string (byte) | Base64-encoded file content. Decode to obtain the raw binary.     |
| `data.fileName`    | string        | Original filename including extension (e.g., `voided_check.pdf`). |
| `data.mimeType`    | string        | MIME type of the file (e.g., `application/pdf`).                  |
| `requestId`        | integer       | Internal request tracking ID.                                     |
| `success`          | boolean       | `true` if the attachment was retrieved successfully.              |
| `error`            | string        | Error message if the operation failed.                            |
| `validationErrors` | array         | List of field-level validation issues.                            |

```json
{
  "data": {
    "content": "JVBERi0xLjQKJcfs4AAQSkZjRgABAQAAAQABAAD...",
    "fileName": "voided_check.pdf",
    "mimeType": "application/pdf"
  },
  "requestId": 98126,
  "success": true,
  "error": null,
  "validationErrors": []
}
```

### Error Codes

| Code | When it happens                                                        |
| ---- | ---------------------------------------------------------------------- |
| 400  | Missing or invalid query parameters (`id`, `ticketId`, or `attachId`). |
| 401  | Invalid or missing Basic Auth credentials.                             |
| 403  | User does not have permission for this operation.                      |
| 404  | Ticket or attachment not found for the given IDs.                      |
| 500  | Internal server error.                                                 |

### Common Mistakes

* Confusing `id` (merchant profile ID) with `attachId` (attachment ID) — all three parameters are distinct and required.
* Using an `attachId` from a different ticket — each attachment ID is scoped to its parent ticket.
* Not decoding the Base64 `content` field before attempting to open or display the file.
* Calling this endpoint without first listing attachments via `getAttachmentsByTicketId` to confirm the attachment exists.

### Related Endpoints

* `GET /api/v1/tickets/getAttachmentsByTicketId` — List all attachment metadata for a ticket to obtain valid `attachId` values.
* `POST /api/v1/tickets/attachment` — Upload a new attachment to a ticket.
* `GET /api/v1/tickets/getTicketById` — Retrieve ticket details including the `hasAttachment` flag.

### Example

```bash
curl -X GET "https://hq.staging.netevia.dev/api/v1/tickets/getAttachmentById?id=70269&ticketId=48291&attachId=1034" \
  -H "Authorization: Basic $(echo -n 'username:password' | base64)"
```

# OpenAPI definition

```json
{
  "openapi": "3.0.0",
  "info": {
    "version": "v1",
    "title": "Netevia HQ | API Documentation",
    "description": "Netevia HQ | API Documentation"
  },
  "paths": {
    "/api/v1/tickets/getAttachmentById": {
      "get": {
        "tags": [
          "Ticket"
        ],
        "operationId": "Ticket_GetAttachmentById",
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "ticketId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "attachId",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiResult1_TicketAttachmentContentResponse"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiResult1_TicketAttachmentContentResponse"
                }
              },
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/ApiResult1_TicketAttachmentContentResponse"
                }
              },
              "text/xml": {
                "schema": {
                  "$ref": "#/components/schemas/ApiResult1_TicketAttachmentContentResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "security": [
    {
      "Basic": []
    }
  ],
  "servers": [
    {
      "url": "https://hq.staging.netevia.dev"
    }
  ],
  "components": {
    "securitySchemes": {
      "Basic": {
        "type": "http",
        "description": "Basic HTTP Authentication",
        "scheme": "basic"
      }
    },
    "schemas": {
      "ValidationError": {
        "type": "object",
        "properties": {
          "field": {
            "type": "string"
          },
          "error": {
            "type": "string"
          }
        }
      },
      "ApiResult1_TicketAttachmentContentResponse": {
        "type": "object",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/TicketAttachmentContentResponse"
          },
          "requestId": {
            "format": "int32",
            "type": "integer"
          },
          "success": {
            "type": "boolean"
          },
          "error": {
            "type": "string"
          },
          "validationErrors": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            }
          }
        }
      },
      "TicketAttachmentContentResponse": {
        "type": "object",
        "properties": {
          "content": {
            "format": "byte",
            "type": "string"
          },
          "fileName": {
            "type": "string"
          },
          "mimeType": {
            "type": "string"
          }
        }
      }
    }
  }
}
```