---
category: [Administration & Integrations, Platform and Product Extensions, Platform and Product Extensions/Integration, Administration & Integrations/Custom Integrations & Apps, Platform and Product Extensions/Workday Extend]
keyword: [Extend, Workday Graph API, Graph API, GraphQL]
nav: wcp_docs
parent_url: /wcp_docs/
title: Graph API Attachments
layout: subsection
---

Workday Graph API enables you to:

-   Upload attachments by calling a Graph API mutation that includes fields of the File type. Graph API performs a virus scan of all attachment uploads.
-   Download attachments by calling:

    -   A Graph API query that gets the `downloadID` of the file attachments.
    -   The Attachments REST API that immediately uses the `downloadID`s to download the attachments.



## <a id="section_1"></a>Mutations with File Attachments

A mutation whose `input` argument contains fields of the `File` scalar type enables you to upload file attachments with the mutation. The `File` type is a named reference to the file part in a multipart/form-data request. The referenced part in the multipart request contains the binary content of the file.

Example: The `createQuickExpense` mutation can accept attachments. The input for the `createQuickExpense` mutation contains `attachments`, which is a list of `attachmentContent` fields of the `File` type. This listing illustrates the Documentation Explorer path that leads to the sample `attachmentContent` field in the schema.

```
createQuickExpense
Arguments
input: Expense_EntryServiceRepresentation_CreateInput
 Fields
 attachments:[Expense_ExpenseEntryImage_CreateEmbeddedInput!]
   Expense_ExpenseEntryImage_CreateEmbeddedInput
     Fields
     attachmentContent: File
```

## <a id="section_2"></a>Graph API Multipart Request

The Graph API endpoint conforms to the [GraphQL Multipart Request specification](https://workday.github.io/graphql-multipart-request-spec/graphql-multipart-request-v3.html), and enables you to submit file attachments in a multipart/form-data request.

The Graph API endpoint is a multipart request:

```
POST https://api.workday.com/graphql/{version}
```

The multipart request body consists of these fields:

-   <b>operations</b>

    (Required) A JSON object containing these fields:

    -   <b>query</b>

        (Required) A single line string containing the mutation operation whose input contains a field of the `File` type. This field of the `File` type can have any name (example:<i>attachmentContent</i>). For this field, specify a reference name of the form part containing the binary file. If the mutation supports a list of attachments, specify a unique reference name for each attachment field.

    -   <b>variables</b>

        (Optional) A JSON map containing the input variables.


-   <b>partName1</b>

    (Required) The referenced name of the part containing the file. <i>partName1</i> must be a string that matches the corresponding part name in the mutation input.

-   <b>partNameN</b>

    (Optional) The referenced name of another part containing the file, if uploading multiple files. <i>partNameN</i> must be a string that matches the corresponding part name in the mutation input.



## <a id="section_3"></a>Uploading Attachments

To upload a file attachment to a business object:

1.  In the Graph API schema, find the mutation that submits file attachments.

    Ensure that the mutation input object contains a field of the `File` type, such as the `attachmentContent` field.

2.  Set the `Content-Type` HTTP header to "multipart/form-data".
3.  Specify the Graph API endpoint.

    Example:

    ```
    POST https://api.workday.com/graphql/{version}
    ```

4.  Specify the mutation, variables, and file parts in the multipart request body.

    In the input argument, specify the field of the `File` type with a reference name. Example:<i>file1</i>.

    In the response data, Include the`workdayID {id}` of the returned object. You’ll need this to download the attachments.

5.  Submit the Graph API request.


To test uploading mutation attachments, you can use the <b>Multipart Attachments</b> panel in the Graph API Explorer. For details, see <i>Multipart Attachments</i> in [Graph API Explorer](/wcp_docs/jfi1654276754280.html).

Example: The `createQuickExpense` mutation accepts an input argument that includes attachments, each of which is an `attachmentContent` field of File type.

```
mutation createQuickExpense(
    $createQuickExpense_input: Expense_EntryServiceRepresentation_CreateInput!) {
  createQuickExpense(input: $createQuickExpense_input) {
    workdayID {
      id
    }
  }
}
 
```

The sample <i>$createQuickExpense_input</i> variable contains `attachments`, which is a list of `attachmentContent` fields:

```
{
"createQuickExpense_input": {
 "attachments":  [
   {
     "attachmentContent": "file1"
   },
   {
     "attachmentContent": "file2"
   }
 ],
 "date": "2024-10-04",
 "expenseItem": {
   "id": {
     "id": "Miscellaneous",
     "type": "Expense_Item_ID"
   }
 },
 "amount": {
   "currency": "USD",
   "value": 200.00
 },
 "memo": "group lunch",
 "merchant": "Data Diner"
}
}
```

Here’s the sample response:

```
{
"data": {
 "createQuickExpense": {
   "workdayID": {
     "id": "c1c505fcf6110100245cb60433080000"
   }
 }
}
}
```

<b>Note:</b> We’ll need the returned Workday ID to query the object instance for downloading the file attachments. In the sample response data from the `createQuickExpense` mutation, the path to the Workday ID is `data.createQuickExpense.workdayID.id`.

## <a id="section_4"></a>Queries with Download ID

A query that supports Graph API file attachments provides the `downloadID` field. To download an attachment using Graph API, you’ll need to get the `downloadID` of the file attachment.

Example: The `expenseReportLine` query returns `lineAttachments`, which is a collection of Attachments containing the `downloadID`. This listing illustrates the Documentation Explorer path that leads to the `downloadID` field in the schema.

```
expenseReportLine  
  Type  
  ExpenseReportLine_Collection  
  Fields
    data: [ExpenseReportLine!]!  
       ExpenseReportLine
       Fields
         lineAttachments: Attachment_Collection
           Attachment_Collection
           Fields
             data: [Attachment!]!
               Attachment
               Fields
                 downloadID
```

<b>Note:</b> The`downloadID`has a 1-hour expiration.

## <a id="section_5"></a>Downloading Attachments

To download a file attachment of a business object:

1.  In the Graph API schema, find the query that returns the instance containing the file attachments.

    Ensure that the attachment type in the data collection contains the `downloadID` field.

2.  Specify the Graph API endpoint.

    ```
    POST https://api.workday.com/graphql/{version}
    ```

    If you use the Graph API Explorer, it automatically uses this endpoint.

3.  Specify the query that gets the instance containing the file attachments.

    If you saved the Workday ID of the returned instance from the mutation that uploaded the attachments, you can use the Workday ID in the query filter.

    In the response data, include the `downloadID`, which is required for downloading the file.

4.  Submit the Graph API request.
5.  Call the Attachments REST API.

    ```
    GET https://api.workday.com/attachments/v1/graphql/{downloadID}
    ```

    Specify the `downloadID` path parameter using the returned `downloadID` from the query

    The Attachments REST API returns the file attachment.



Example: This sample query gets the `downloadID` of the file attachment submitted in the previous mutation example.

```
query getAttachments($expenseReportLine_dataSource: ExpenseReportLine_DataSources!) {
expenseReportLine(dataSource: $expenseReportLine_dataSource) {
 data {
   lineAttachments {
     data {
       downloadID
       descriptor
       contentType
     }
   }
 }
}
}
```

The sample variable containing the Workday ID of the expense object returned from the previous mutation:

```
{
"expenseReportLine_dataSource": {
 "expenseReportLinesForWorker": {
   "filter": {
     "expenseReportLineFilter": {
       "quickExpense": {
         "id": "c1c505fcf6110100245cb60433080000",
         "type": "WID"
       }
     }
   }
 }
}
}
```

Sample response:

```
{
"data": {
 "expenseReportLine": {
   "data": [
     {
       "lineAttachments": {
         "data": [
           {
             "descriptor": "receipt.png",
             "contentType": "image/png",
             "downloadID": "VjBSRFF6RXVNSUVBRVFBQURLdWlZdTE1TXkyNnBoZm1DUUFBakFBV0FURUFFRVRpbnhkcXViSUdKRllJandkZElwVUFBQUQ1UjhmTkszZnowRUxndVBlZE0wcm1DZW1KZTZaYnVRaEcrL2dveHlwY2JFMy9hZnFUNmdodStwNGZxMVhiMGNmeWFFZGVwQUduS1lBd1VzVXNZcjN2dHZuM0R1T0s"
           },
           {
             "descriptor": "lunchReceipt.pdf",
             "contentType": "application/pdf",
             "downloadID": "VjBSRFF6RXVNSUVBRVFBQURKL05FVzE5Z3dMSkVoQTF4d0FBakFBV0FURUFFTWl4WkMraGwzOXJKekVOaTk1ckk4SUFBQURVYm95dVRWRTBWKzliV01CamxmSm5tVDE4djZhaFR2QTlTaVQrUWpNTUU0emZEcnVtdmlpNXRyQWJ0Vi9WbWhoOVY4eCt1c2NnNjhjQnNzaENuUkJ4bHNkSy9zNDk"
           }
         ]
       }
     }
   ]
 }
}
}
```

<b>Note:</b> We’ll need the `downloadID` to download each file attachments. In the sample response data from the `expenseReportLine` query, the path to the downloadID is `data.expenseReportLine.data[0].lineAttachments.data[0].downloadID`.

Sample Attachments REST API call for the first attachment:

```
GET https://api.workday.com/attachments/v1/graphql/VjBSRFF6RXVNSUVBRVFBQURLdWlZdTE1TXkyNnBoZm1DUUFBakFBV0FURUFFRVRpbnhkcXViSUdKRllJandkZElwVUFBQUQ1UjhmTkszZnowRUxndVBlZE0wcm1DZW1KZTZaYnVRaEcrL2dveHlwY2JFMy9hZnFUNmdodStwNGZxMVhiMGNmeWFFZGVwQUduS1lBd1VzVXNZcjN2dHZuM0R1T0s
```

The Attachments REST API returns the file attachment. If you use the REST API Explorer for testing the call, you can download or view the file attachment.

