# Get multiple files

URL: https://docs.sparklayer.io/developers/api/files/get-bulk-files
Operation: `GET /api/v1/files` (operationId `getBulkFiles`)
OpenAPI spec: https://docs.sparklayer.io/openapi/files.yaml

Returns the files whose IDs you pass in `ids`; repeat the parameter for each ID (`?ids=…&ids=…`). IDs that do not exist, or whose files have been deleted or have expired, are left out of the response. If any requested file failed its post-upload checks, the whole request returns `410`.

`GET /api/v1/files`

**Base URLs:** `https://app.sparklayer.io` (Live), `https://test.app.sparklayer.io` (Test)

**Authentication:** send `Authorization: Bearer <access_token>` and `Site-Id: <site id>` with every request. Get the token from [Get an access token](https://docs.sparklayer.io/developers/api/core/get-an-access-token.md); see [Authentication](https://docs.sparklayer.io/developers/authentication.md).

### Example request

```bash
curl "https://app.sparklayer.io/api/v1/files?ids=86027e2c-e853-11ee-b1d4-7c214a6ed8c7" \
  -H "Authorization: Bearer $SPARKLAYER_TOKEN" \
  -H "Site-Id: $SPARKLAYER_SITE_ID"
```

Set `SPARKLAYER_TOKEN` to an access token and `SPARKLAYER_SITE_ID` to your Site ID. For the test environment, use `https://test.app.sparklayer.io`.

### Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `ids` | string[] | Yes | The IDs of the files to get. Repeat the parameter for each ID (`?ids=…&ids=…`). Example: `86027e2c-e853-11ee-b1d4-7c214a6ed8c7` |

### Header parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `Site-Id` | string | Yes | Your SparkLayer Site ID, from Settings > API in the SparkLayer Dashboard. Example: `jones-climbing` |

### Responses

#### 200: The requested files that exist. IDs that don't, or whose files were deleted or expired, are left out.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `file_handle` | object | | |
| `file_handle.file_path` | string | | The path to the file, including the file name |
| `file_handle.id` | string | | The ID of this type |
| `file_handle.url` | string \| null | | URL to download/upload the file. For GET, this will be a readable link. If the file is not ready, this will be `null`. For POST/PATCH this will be a writeable link |
| `file_handle.required_headers` | object[] | | An array of headers you must include in the file upload/download request |
| `file_handle.required_headers[].name` | string | | Name of the header |
| `file_handle.required_headers[].value` | string | | Value of the header |
| `ready` | boolean | | Whether the file has been fully uploaded and verified |
| `mime_type` | string | | The mime type of this file |
| `file_size` | integer | | The size of this file in bytes |
| `created_at` | string (date-time) | | The date at which the file was created (RFC-3339) |
| `updated_at` | string (date-time) | | The date at which the file was updated (RFC-3339) |
| `metadata` | object | | |

```json
{
  "file_handle": {
    "file_path": "folder/file.png",
    "id": "86027e2c-e853-11ee-b1d4-7c214a6ed8c7",
    "url": "https://files.sparklayer.io/siteId/siteEnv/path/to/file.png.",
    "required_headers": [
      {
        "name": "Content-Type",
        "value": "application/pdf"
      }
    ]
  },
  "ready": true,
  "mime_type": "image/png",
  "file_size": 255,
  "created_at": "2020-01-01T00:00:00+02:00",
  "updated_at": "2020-01-01T00:00:00+02:00",
  "metadata": {
    "sparklayer": {
      "forms": {
        "context": "email_template",
        "step_id": "erkjs"
      },
      "emails": {
        "attachments": [
          "86027e2c-e853-11ee-b1d4-7c214a6ed8c7"
        ]
      }
    }
  }
}
```

#### Other statuses: An error. The body describes the problem: see [Errors](https://docs.sparklayer.io/developers/errors.md).

`application/problem+json`: the standard error body (below).

### Error body

Error responses with a body use this RFC 7807 problem details object. See [Errors](https://docs.sparklayer.io/developers/errors.md) for every status code and which errors to retry.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `detail` | string | | Human-readable summary of the error |
| `status` | integer | | HTTP Status code returned from API |
| `title` | string | | Machine-readable error code |
| `type` | string \| null | | |
| `errors` | object[] \| null | | A list of errors related to the call |
| `errors[].code` | string | | Machine-readable error code |
| `errors[].property` | string | | The property the error relates to |
| `errors[].message` | string | | Human readable summary of the error |

```json
{
  "detail": "Data Validation Failed",
  "status": 400,
  "title": "invalid-api-request-contents",
  "type": "https://docs.sparklayer.io/api/errors#invalid-api-request-contents",
  "errors": [
    {
      "code": "resource-not-found",
      "property": "template",
      "message": "template not found"
    }
  ]
}
```
