Reference · Directories

# POST/directory

Creates a directory. A directory holds a task’s inputs and outputs, and is deleted with everything in it when its `ttl` runs out. You don’t have to create one: `POST /file` without a `dir_id` makes one for you.

## Request body

Request body

- `ttl` (number): How long the directory lives, in seconds. 86400 (24 hours) when left out; a longer value than 604800 (7 days) is brought down to that.

The body may be left out altogether, or be {}.

## Example

Request

```bash
curl https://media.logicboostkit.com/directory \
  -H "Authorization: Basic $MEDIA_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "ttl": 3600 }'
```

Response

```http
HTTP/1.1 200 OK
X-Request-Id: job_0mv6img4ztlm392wz8t7f205

{
  "ok": true,
  "directory": {
    "id": "dir_m8papv92jrn8rx6186g8",
    "ttl": 3600
  }
}
```

## Response fields

Response fields

- `ok` (boolean): true when the directory was created.
- `directory.id` (string): The directory’s id: dir_ and 20 lower-case letters and digits.
- `directory.ttl` (number): Its lifetime in seconds, as applied.

## Status codes

Status codes

- **200**: The directory exists. Not charged.
- **400**: The body isn’t a JSON object, or `ttl` isn’t a positive number.
- **401**: The `Authorization` header is missing, or the key is invalid, revoked or expired.
- **403**: The account isn’t active. The error says what to do.
- **429**: More than 300 requests in a minute on this key. Wait for the number of seconds in `Retry-After`.

Every error has the shape `{"ok": false, "error": "…"}` and is never charged.
