Mail-in-a-Box API HTTP specification.
This API is documented in OpenAPI format. (View the full HTTP specification.)
All endpoints are relative to https://{host}/admin
and are secured with Basic Access
authentication. If you have multi-factor authentication enabled, authentication with a user:password
combination will fail unless a valid OTP is supplied via the x-auth-token
header. Authentication via a user:user_key
pair is possible without the header being present.
Credentials can be supplied using the Authorization
header in
format Authorization: Basic {access-token}
.
The access-token
is comprised of the Base64 encoding of username:password
.
The username
is the mail user's email address, and password
can either be the mail user's
password, or the api_key
returned from the login
operation.
When using curl
, you can supply user credentials using the -u
or --user
parameter.
Security Scheme Type | HTTP |
---|---|
HTTP Authorization Scheme | basic |
Returns user information and a session API key.
Authenticate a user by supplying the auth token as a base64 encoded string in
format email:password
using basic authentication headers.
If successful, a long-lived api_key
is returned which can be used for subsequent
requests to the API in place of the password.
curl -X GET "https://{host}/admin/login" \ -u "<email>:<password>"
{- "reason": "Incorrect username or password",
- "status": "invalid"
}
Mail operations, which include getting all users, getting all aliases, adding/updating/removing users and aliases and getting all mail domains.
Returns all mail users.
format | string (MailUsersResponseFormat) Enum: "text" "json" Example: format=json The format of the response. |
curl -X GET "https://{host}/admin/mail/users?format=<string>" \ -u "<email>:<password>"
[- {
- "domain": "example.com",
- "users": [
- {
- "email": "user@example.com",
- "privileges": [
- "admin"
], - "status": "active",
- "mailbox": "/home/user-data/mail/mailboxes/example.com/user"
}
]
}
]
Adds a new mail user.
email required | string <email> (Email) Email format. |
password required | string <password> |
privileges required | string (MailUserPrivilege) Enum: "admin" "" Mail user privilege. |
email=user%40example.com&password=s3curE_pa5Sw0rD&privileges=
mail user added
updated DNS: OpenDKIM configuration
Removes an existing mail user.
email required | string <email> (Email) Email format. |
email=user%40example.com
OK
Adds a privilege to an existing mail user.
email required | string <email> (Email) Email format. |
privilege required | string (MailUserPrivilege) Enum: "admin" "" Mail user privilege. |
email=user%40example.com&privilege=admin
OK
Removes a privilege from an existing mail user.
email required | string <email> (Email) Email format. |
privilege required | string (MailUserPrivilege) Enum: "admin" "" Mail user privilege. |
email=user%40example.com&privilege=admin
OK
Sets a password for an existing mail user.
email required | string <email> (Email) Email format. |
password required | string <password> |
email=user%40example.com&password=s3curE_pa5Sw0rD
OK
Returns all privileges for an existing mail user.
string <email> (Email) Example: email=user@example.com The email you want to get privileges for. |
curl -X GET "https://{host}/admin/mail/users/privileges?email=<email>" \ -u "<email>:<password>"
admin
curl -X GET "https://{host}/admin/mail/domains" \ -u "<email>:<password>"
example1.com example2.com
Returns all mail aliases.
format | string (MailAliasesResponseFormat) Enum: "text" "json" Example: format=json The format of the response. |
curl -X GET "https://{host}/admin/mail/aliases?format=<string>" \ -u "<email>:<password>"
[- {
- "domain": "example.com",
- "aliases": [
- {
- "address": "user@example.com",
- "address_display": "user@example.com",
- "forwards_to": [
- "user@example.com"
], - "permitted_senders": [
- "user@example.com"
], - "required": true
}
]
}
]
Adds or updates a mail alias. If updating, you need to set update_if_exists: 1
.
update_if_exists required | integer <int32> [ 0 .. 1 ] Set to |
address required | string <email> (Email) Email format. |
forwards_to required | string If adding a regular or catch-all alias, the format needs to be If adding a domain alias, the format needs to be |
permitted_senders required | string or null Mail users that can send mail claiming to be from any address on the alias domain. Multiple address can be separated by newlines or commas. Leave empty to allow any mail user listed in |
update_if_exists=0&address=user%40example.com&forwards_to=user2%40example.com&
alias updated
Removes a mail alias.
address required | string <email> (Email) Email format. |
address=user%40example.com
alias removed
DNS operations, which include adding custom records, adding a secondary nameserver and viewing all DNS records.
Adds one or more secondary nameservers.
hostnames required | string Hostnames separated with commas or spaces. |
hostnames=ns2.hostingcompany.com%2C%20ns3.hostingcompany.com
updated DNS: example.com
curl -X GET "https://{host}/admin/dns/zones" \ -u "<email>:<password>"
[- "example.com"
]
Returns a DNS zone file for a hostname.
zone required | string <hostname> (Hostname) Example: example.com Hostname |
curl -X GET "https://{host}/admin/dns/zonefile/<zone>" \ -u "<email>:<password>"
"string"
Updates the DNS. Involves creating zone files and restarting nsd
.
force required | integer <int32> [ 0 .. 1 ] Force an update even if mailinabox detects no changes are required. |
force=1
"updated DNS: example1.com,example2.com\n"
curl -X GET "https://{host}/admin/dns/custom" \ -u "<email>:<password>"
[- {
- "qname": "example.com",
- "rtype": "MX",
- "value": "10 example.com."
}
]
Returns all custom records for the specified query name and type.
qname required | string <hostname> (Hostname) Example: example.com DNS record query name |
rtype required | any (DNSRecordType) Enum: "A" "AAAA" "CAA" "CNAME" "TXT" "MX" "SRV" "SSHFP" "NS" Example: MX Record type |
curl -X GET "https://{host}/admin/dns/custom/<qname>/<rtype>" \ -u "<email>:<password>"
[- {
- "qname": "example.com",
- "rtype": "MX",
- "value": "10 example.com."
}
]
Adds a custom DNS record for the specified query name and type.
qname required | string <hostname> (Hostname) Example: example.com DNS record query name |
rtype required | any (DNSRecordType) Enum: "A" "AAAA" "CAA" "CNAME" "TXT" "MX" "SRV" "SSHFP" "NS" Example: MX Record type |
The value of the DNS record.
1.2.3.4
updated DNS: example.com
Updates an existing DNS custom record value for the specified qname and type.
qname required | string <hostname> (Hostname) Example: example.com DNS record query name |
rtype required | any (DNSRecordType) Enum: "A" "AAAA" "CAA" "CNAME" "TXT" "MX" "SRV" "SSHFP" "NS" Example: MX Record type |
The value of the DNS record.
1.2.3.4
updated DNS: example.com
Removes a DNS custom record for the specified domain, type & value.
qname required | string <hostname> (Hostname) Example: example.com DNS record query name |
rtype required | any (DNSRecordType) Enum: "A" "AAAA" "CAA" "CNAME" "TXT" "MX" "SRV" "SSHFP" "NS" Example: MX Record type |
The value of the DNS record.
1.2.3.4
updated DNS: example.com
Returns all custom A records for the specified query name.
qname required | string <hostname> (Hostname) Example: example.com DNS query name. |
curl -X GET "https://{host}/admin/dns/custom/<qname>" \ -u "<email>:<password>"
[- {
- "qname": "example.com",
- "rtype": "MX",
- "value": "10 example.com."
}
]
Adds a custom DNS A record for the specified query name.
qname required | string <hostname> (Hostname) Example: example.com DNS query name. |
The value of the DNS record.
1.2.3.4
updated DNS: example.com
Updates an existing DNS custom A record value for the specified qname.
qname required | string <hostname> (Hostname) Example: example.com DNS query name. |
The value of the DNS record.
1.2.3.4
updated DNS: example.com
Removes a DNS custom A record for the specified domain & value.
qname required | string <hostname> (Hostname) Example: example.com DNS query name. |
The value of the DNS record.
1.2.3.4
updated DNS: example.com
curl -X GET "https://{host}/admin/dns/dump" \ -u "<email>:<password>"
[- [
- "example1.com",
- [
- {
- "explanation": "Required. Specifies the hostname (and priority) of the machine that handles @example.com mail.",
- "qname": "example1.com",
- "rtype": "MX",
- "value": "10 box.example1.com."
}
]
], - [
- "example2.com",
- [
- {
- "explanation": "Required. Specifies the hostname (and priority) of the machine that handles @example.com mail.",
- "qname": "example2.com",
- "rtype": "MX",
- "value": "10 box.example2.com."
}
]
]
]
TLS (SSL) Certificates operations, which include checking certificate status and installing custom certificates.
curl -X GET "https://{host}/admin/ssl/status" \ -u "<email>:<password>"
{- "can_provision": [
- "string"
], - "status": [
- {
- "domain": "example.com",
- "status": "success",
- "text": "Signed & valid. The certificate expires in 87 days on 10/28/20."
}
]
}
Generates a Certificate Signing Request (CSR) for a domain & country code.
domain required | string <hostname> (Hostname) Example: example.com Domain to generate CSR for. |
countrycode required | string |
countrycode=GB
-----BEGIN CERTIFICATE REQUEST----- MIICaDCCAVACAQAwIzELMAkGA1UEBhMCQlMxFDASBgNVBAMMC2V4YW1wbGUuY29t ... JmFDQESSfUxLPHLC660Wnf3GmrP/duZHpPC+qTe8b1AlQ7zDT3cOaAQ+Mb0= -----END CERTIFICATE REQUEST-----
Installs a custom certificate. The chain certificate is optional.
domain required | string <hostname> (Hostname) Hostname format. |
cert required | string TLS/SSL certificate. |
chain required | string TLS/SSL intermediate chain (if provided, else empty string). |
domain=example.com&cert=CERT_STRING&chain=CHAIN_STRING
OK
curl -X POST "https://{host}/admin/ssl/provision" \ -u "<email>:<password>"
{- "requests": [
- {
- "log": [
- "The domain name does not resolve to this machine: [Not Set] (A), [Not Set] (AAAA)."
], - "result": "installed",
- "domains": [
- "example.com"
]
}
]
}
Static web hosting operations, which include getting domain information and updating domain root directories.
curl -X GET "https://{host}/admin/web/domains" \ -u "<email>:<password>"
[- {
- "custom_root": "/home/user-data/www/example.com",
- "domain": "example.com",
- "root": "/home/user-data/www/default",
- "ssl_certificate": [
- "No certificate installed.",
- "No certificate installed."
], - "static_enabled": true
}
]
Retrieves which type of MFA is used and configuration
curl -X POST "https://{host}/admin/mfa/status" \ -u "<email>:<password>"
{- "enabled_mfa": {
- "id": "string",
- "type": "string",
- "label": "string"
}, - "new_mfa": {
- "type": "string",
- "secret": "string",
- "qr_code_base64": "string"
}
}
Enables TOTP authentication for the currently logged-in admin user
secret required | string |
code required | string |
label | string |
curl -X POST "https://{host}/admin/mfa/totp/enable" \ -d "code=123456" \ -d "secret=<string>" \ -u "<email>:<password>"
Disables multi-factor authentication for the currently logged-in admin user or another user if a 'user' parameter is submitted. Either disables all multi-factor authentication methods or the method corresponding to the optional property mfa_id
.
mfa_id | string or null |
curl -X POST "https://{host}/admin/mfa/totp/disable" \ -u "<email>:<user_key>"
Returns an array of statuses which can include headings.
curl -X POST "https://{host}/admin/system/status" \ -u "<email>:<password>"
[- {
- "type": "heading",
- "text": "System",
- "extra": [ ]
}, - {
- "type": "warning",
- "text": "This domain's DNSSEC DS record is not set",
- "extra": [
- {
- "monospace": false,
- "text": "Digest Type: 2 / SHA-25"
}
]
}
]
curl -X GET "https://{host}/admin/system/version" \ -u "<email>:<password>"
v0.46
curl -X GET "https://{host}/admin/system/updates" \ -u "<email>:<password>"
libgnutls30 (3.5.18-1ubuntu1.4) libxau6 (1:1.0.8-1ubuntu1)
curl -X POST "https://{host}/admin/system/update-packages" \ -u "<email>:<password>"
Calculating upgrade... The following packages will be upgraded: cloud-init grub-common
Returns system privacy (new-version check) status.
Response:
true
: Private, new-version checks will not be performedfalse
: Not private, new-version checks will be performedcurl -X GET "https://{host}/admin/system/privacy" \ -u "<email>:<password>"
false
Updates system privacy (new-version checks).
Request:
value: private
: Disable new version checksvalue: off
: Enable new version checksvalue required | string (SystemPrivacyStatus) Enum: "private" "off" System privacy status. |
value=off
OK
Returns the system reboot status.
Response:
true
: A reboot is requiredfalse
: A reboot is not requiredcurl -X GET "https://{host}/admin/system/reboot" \ -u "<email>:<password>"
true
curl -X POST "https://{host}/admin/system/reboot" \ -u "<email>:<password>"
No reboot is required, so it is not allowed.
Returns the system backup status.
If the list of backups is empty, this implies no backups have been made yet.
curl -X GET "https://{host}/admin/system/backup/status" \ -u "<email>:<password>"
{- "backups": [
- {
- "date": "20200801T023706Z",
- "date_delta": "15 hours, 40 minutes",
- "date_str": "2020-08-01 03:37:06 BST",
- "deleted_in": "approx. 6 days",
- "full": false,
- "size": 125332,
- "volumes": 1
}
], - "unmatched_file_size": 0,
- "error": "Something is wrong with the backup"
}
curl -X GET "https://{host}/admin/system/backup/config" \ -u "<email>:<password>"
{- "enc_pw_file": "/home/user-data/backup/secret_key.txt",
- "file_target_directory": "/home/user-data/backup/encrypted",
- "min_age_in_days": 3,
- "ssh_pub_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDb root@box.example.com\\n",
- "target": "s3://s3.eu-central-1.amazonaws.com/box-example-com",
- "target_user": "string",
- "target_pass": "string"
}
Updates the system backup config.
target required | string <hostname> |
target_user required | string |
target_pass required | string <password> |
min_age required | integer <int32> >= 1 |
target=s3%3A%2F%2Fs3.eu-central-1.amazonaws.com%2Fbox-example-com&target_user=ACCESS_KEY&target_pass=SECRET_ACCESS_KEY&minAge=3
OK