# POST /api/v1/files/mkdir

> Write a file, make a directory, copy, move or set permissions

- Group: files
- Tier: W
- Required scope: write:files
- Docs: https://api.inleed.com/reference/files/create-files

## Description

`action=write` needs `path` and `content`; `mkdir` needs `path`; `copy`/`move` need `source` and `destination`; `permissions` needs `path` and an octal `mode` (e.g. `0644`). Every path is confined to the account home. All actions require `write:files`.

## Body

- `input` — string (required). A domain, email address, website URL, or Inleed service id — for example example.se, info@example.se or 42976. Resolved to the owning account automatically, and the resolved target is echoed back in the response.
- `action` — enum (required). write a text file, mkdir a directory, copy or move an entry, or set permissions. All require write:files. One of write, mkdir, copy, move, permissions.
- `path` — string. The target path, relative to the account home (e.g. /domains/example.com/public_html/.htaccess).
- `content` — string. The full new text content for action=write (max 256 KB). It is treated as data and never echoed back or logged.
- `source` — string. The path to copy or move from, relative to the account home. Required for copy and move.
- `destination` — string. The directory to copy or move into, relative to the account home. Required for copy and move.
- `mode` — string. The octal permission mode for action=permissions, e.g. 0644 or 755.

## Request

```bash
curl -X POST "https://mcp.inleed.com/api/v1/files/mkdir" \
  -H "Authorization: Bearer inl_live_…" \
  -H "Content-Type: application/json" \
  -d '{"input":"example.se","action":"write","path":"example.se","content":"example.se","source":"example.se","destination":"example.se","mode":"example.se"}'
```

## Errors

- **400**  — codes: invalid_request
- **401** No token was presented, or the token is revoked, expired or unknown. — codes: unauthorized, token_expired, token_revoked
- **403** The token lacks a required scope, or this account does not own the resource. — codes: insufficient_scope, domain_not_owned
- **404** No such resource for this account. — codes: not_found
- **422** Validation error — codes: validation_failed
- **429** The rate limit for this token is exhausted. See `Retry-After`. — codes: rate_limited
- **500** Something went wrong on our side. The failure is logged against `requestId`. — codes: internal_error

## Related

- GET /api/v1/files — https://api.inleed.com/reference/files/list-files
- DELETE /api/v1/files — https://api.inleed.com/reference/files/delete-file

