---
search:
  tags:
    - Data
    - POST
seo:
  description: >-
    Returns a signed URL that downloads one file or, with… Reference for the
    POST /_luna/tenants/{tenant}/files/{type}/{bucket}/sign endpoint in the Luna
    API.
sidebar:
  label: Sign a URL for a file
  badge: POST
title: Sign a URL for a file
type: openapi-operation
---
Returns a signed URL that downloads one file or, with `upload`, uploads it. The URL is a path on the environment's own address and works without a token until it expires. A download URL needs `data:read`. An upload URL needs `data:write`.

`POST /_luna/tenants/{tenant}/files/{type}/{bucket}/sign`

**Request body** (`application/json`, required)

- `key` (any, required) — The luna's key as JSON, such as \`{"id":"a"}\`. For a type keyed by one field, the value of that field alone also works.
- `path` (string, required) — The file's path in the bucket.
- `upload` (boolean | null) — True for a URL that uploads the file with \`PUT\`. False, the default, for one that downloads it with \`GET\`.
- `expiresInMs` (integer<int64> | null) — How long the URL works for, in milliseconds.
- `contentType` (string | null) — The content type an upload must send.
- `maxSize` (integer<int64> | null) — The largest upload the URL accepts, in bytes.

Request body example:

```json
{
  "key": null,
  "path": "string",
  "upload": true,
  "expiresInMs": 0,
  "contentType": "string",
  "maxSize": 0
}
```

**Responses**

- `200` — The signed URL.
- `default` — The request failed. The status says how and \`error.message\` says why.

Response example, 200:

```json
{
  "url": "string",
  "method": "string",
  "expires": 0
}
```
