---
title: "Attachments - REST v2"
canonical: "https://docs.getxray.app/space/XRAYCLOUD/44577090/Attachments%20-%20REST%20v2"
format: markdown
---
There are two endpoints regarding attachments in Xray.


|  |  |
| --- | --- |
| Get attachment | <span style="color: #FF9900">**/api/v2/attachments/{attachmentId}**</span> |
| Add attachment | <span style="color: #FF9900">**/api/v2/attachments**</span> |

## Get attachment

To get attachments, you can use the following endpoint:

> Macro (rw-ui-expands-macro)
> 
> > Macro (rw-expand)
> 
> > ℹ️ ### <span style="color: #003366">**Request**</span>
> > ℹ️ 
> > ℹ️ ###### <span style="color: #003366">**PARAMETERS**</span>
> > ℹ️ 
> > ℹ️ > Macro (legacy-content)
> > ℹ️ 
> > ℹ️ 
> > ℹ️ ###### <span style="color: #003366">**Example:**</span>
> > ℹ️ 
> > ℹ️ > Macro (legacy-content)
> > ℹ️ 
> > ℹ️ ### <span style="color: #003366">**Responses**</span>
> > ℹ️ 
> > ℹ️ <span style="color: #FFFFFF">200 OK</span> : **octet/stream** : Successful. The attachment is retrieved.  
> > ℹ️ 
> > ℹ️ 
> > ℹ️ <span style="color: #FFFFFF">400 BAD_REQUEST</span> : **application/json**** ****:**** **The attachment could not be retrieved.  
> > ℹ️ **Example Output**
> > ℹ️ 
> > ℹ️ > Macro (legacy-content)
> > ℹ️ 
> > ℹ️   
> > ℹ️   
> > ℹ️ <span style="color: #FFFFFF">**401 UNAUTHORIZED**</span>**: application/json: **The API token is invalid.

## Add attachment

<span style="color: #000000"> To add attachments, you can use the following endpoint:</span>

> Macro (rw-ui-expands-macro)
> 
> > Macro (rw-expand)
> 
> |  |
> | --- |
> | ### <span style="color: #003366">**Request**</span><br><span style="color: #5e6c84">**E**</span><span style="color: #003366">**xample**</span><br>> ✅ **Example Request**
> > ✅ 
> > ✅ curl -H "Content-Type: multipart/form-data" -X POST -F attachment=@report.pdf -H "Authorization: Bearer $token" [https://xray.cloud.getxray.app/api/v2/attachments](https://xray.cloud.xpand-it.com/api/v1/attachments)<br>### <span style="color: #003366">**Responses**</span>** **<br>200 OK : **application/json** : Successful. The attachment was added.<br>##### **Example Output**<br>```
> {
>   "id": "7e0073ec-cc9a-44fa-a2da-9d8c163caeae",
>   "filename": "report.pdf",
>   "created": "2020-06-28T16:59:33.051Z",
>   "size": 123446
> }
> ```<br>400 BAD_REQUEST : **application/json**** : **The attachment information was not provided.<br>##### **Example Output**<br>```
> {
>   "error": "No file found."
> }
> ```<br>401 UNAUTHORIZED : **application/json** : The Xray license is not valid. |