## POST /api/v2/shared-hosting/{accountId}/email-accounts/{address}/actions/mail-profile-link

**Create an Apple Mail setup link**

Creates a link to the Apple Mail setup profile of one mailbox that opens without a login, for example as a QR code to scan with an iPhone. The link works for 30 minutes and points at `GET /api/v2/mail-profiles/{token}`. It can be opened any number of times until then. After that it answers 410 `link_expired`. Create a new link. The profile holds the mail servers, the ports and the username, never a password. To download the same profile with your API key, use `GET /api/v2/shared-hosting/{accountId}/email-accounts/{address}/mobileconfig`. The mailbox domain must be on the account. The link is made for any address on such a domain. The call does not check that the mailbox exists. List the mailboxes with `GET /api/v2/shared-hosting/{accountId}/email-accounts` first.

### Related Endpoints

- `POST /api/v2/shared-hosting/{accountId}/email-accounts/{address}/actions/sso`: Create a webmail login link
- `DELETE /api/v2/shared-hosting/{accountId}/email-accounts/{address}`: Delete an email account
- `PUT /api/v2/shared-hosting/{accountId}/email-accounts/{address}/quota`: Change an email account quota

### Headers

- `Authorization`: Bearer $HOSTUP_API_KEY
- Scopes: `read:hosting`, `console:services`

### Parameters

- `accountId` (path, string, required): The hosting account ID (`acct_…`). Example: `acct_01hxa3b4c5d6e7f8g9h0j1k2m3`
- `address` (path, string, required): The email address (`hello@example.com`) or the email account ID (`mail_…`). Unicode IDN and punycode spellings are both accepted. Example: `hello@example.com`

### Request Example

```bash
curl -X POST "https://cloud.hostup.se/api/v2/shared-hosting/acct_01hxa3b4c5d6e7f8g9h0j1k2m3/email-accounts/hello@example.com/actions/mail-profile-link" \
  -H "Authorization: Bearer $HOSTUP_API_KEY" \
  -H "Content-Type: application/json"
```

### Response Schema

- `url` (string, required): Download link for the setup profile. It opens without a login. Example: `https://cloud.hostup.se/api/v2/mail-profiles/YOUR_TOKEN`
- `expiresAt` (string, required): When the link stops working, 30 minutes after it was created. Example: `2026-09-24T10:30:00.000Z`

### Responses

#### 200 - The setup link.
```json
{
  "url": "https://cloud.hostup.se/api/v2/mail-profiles/YOUR_TOKEN",
  "expiresAt": "2026-09-24T10:30:00.000Z"
}
```

#### 400 - `{address}` is not a valid email address or a known email account ID.
```json
{
  "type": "https://developer.hostup.se/errors/invalid_request",
  "title": "Invalid request",
  "status": 400,
  "detail": "Invalid email address.",
  "code": "invalid_request",
  "instance": "/api/v2/shared-hosting/acct_01hxa3b4c5d6e7f8g9h0j1k2m3/email-accounts/hello%40example.com/actions/mail-profile-link",
  "errors": [
    {
      "pointer": "/path/address",
      "detail": "Invalid email address.",
      "code": "invalid_request"
    }
  ]
}
```

#### 401 - Unauthorized. Authentication is required.
```json
{
  "type": "https://developer.hostup.se/errors/unauthorized",
  "title": "Unauthorized",
  "status": 401,
  "detail": "Authentication is required.",
  "code": "unauthorized",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 403 - The mailbox domain is not on this hosting account (`domain_not_owned`), the API key lacks a required scope or the account is not active.
```json
{
  "type": "https://developer.hostup.se/errors/domain_not_owned",
  "title": "Domain not owned by hosting account",
  "status": 403,
  "detail": "The requested domain is not hosted on this cPanel account.",
  "code": "domain_not_owned",
  "instance": "/api/v2/shared-hosting/acct_01hxa3b4c5d6e7f8g9h0j1k2m3/email-accounts/hello%40example.com/actions/mail-profile-link"
}
```

#### 404 - Not found. The resource does not exist or is not owned by the caller.
```json
{
  "type": "https://developer.hostup.se/errors/not_found",
  "title": "Not found",
  "status": 404,
  "detail": "The requested resource could not be found.",
  "code": "not_found",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 409 - The account is on Hostup's previous hosting platform. A setup profile is only made for accounts on cPanel.
```json
{
  "type": "https://developer.hostup.se/errors/account_not_eligible_cpanel",
  "title": "Control panel action unavailable",
  "status": 409,
  "detail": "A mail setup profile can only be provided for hosting accounts on the cPanel control panel. This account uses HostUp's previous hosting platform. Contact support and we will migrate the existing account to cPanel at no extra charge; no new hosting plan is needed.",
  "code": "account_not_eligible_cpanel",
  "instance": "/api/v2/shared-hosting/acct_01hxa3b4c5d6e7f8g9h0j1k2m3/email-accounts/hello%40example.com/actions/mail-profile-link"
}
```

#### 429 - Rate limited. Retry after the limit resets. 429 responses include `Retry-After` seconds plus `X-RateLimit-*` headers.
```json
{
  "type": "https://developer.hostup.se/errors/rate_limit_exceeded",
  "title": "Too many requests",
  "status": 429,
  "detail": "Rate limit exceeded. Please try again later.",
  "code": "rate_limit_exceeded",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 500 - Internal error. Retry later or contact support if the issue persists.
```json
{
  "type": "https://developer.hostup.se/errors/internal_error",
  "title": "Internal server error",
  "status": 500,
  "detail": "An unexpected error occurred. Retry later or contact support if the issue persists.",
  "code": "internal_error",
  "instance": "/api/v2/resource",
  "requestId": "req_01hxa3b4c5d6e7f8g9h0j1k2m3",
  "timestamp": "2026-04-27T12:34:56.000Z"
}
```

#### 502 - The account's domains could not be read to check the address (`upstream_failed`). Try again later.
```json
{
  "type": "https://developer.hostup.se/errors/upstream_failed",
  "title": "Upstream request failed",
  "status": 502,
  "detail": "Unable to verify domain ownership against the hosting account.",
  "code": "upstream_failed",
  "instance": "/api/v2/shared-hosting/acct_01hxa3b4c5d6e7f8g9h0j1k2m3/email-accounts/hello%40example.com/actions/mail-profile-link"
}
```
