Subaccounts

Mailgun supports the creation, modification, and deletion of subaccounts. A subaccount is a child account of a parent account. The parent account can have multiple subaccounts. The subaccounts are created and managed by the parent account.

Get a single subaccount

get/v5/accounts/subaccounts/{subaccount_id}

Fetch the details of a single subaccount

SecuritybasicAuth
Request
path Parameters
subaccount_id
required
string

The ID of the subaccount

Responses
200

A 200 response

Response Schema: application/json
object
id
string

The ID of the subaccount

name
string

The name of the subaccount

status
string

The status of the subaccount

Enum: "disabled" "open"
404

A 404 response

Request samples
Response samples
application/json
{
  • "subaccount": {
    • "id": "123",
    • "name": "My subaccount",
    • "status": "open"
    }
}

List all subaccounts

get/v5/accounts/subaccounts

Fetch all subaccounts

SecuritybasicAuth
Request
query Parameters
sort
string

Sort order

Enum: "asc" "desc"
filter
string

Name of account to filter by

limit
integer [ 1 .. 1000 ]
Default: 10

Number of subaccounts to return

skip
integer
Default: 0

Number of subaccounts to skip

enabled
boolean

Indicate to include only enabled or disabled subaccounts

Responses
200

A 200 response

Response Schema: application/json
Array of objects
total
integer

The total number of subaccounts

Request samples
Response samples
application/json
{
  • "subaccounts": [
    • {
      }
    ],
  • "total": 1
}

Create a subaccount

post/v5/accounts/subaccounts

Create a subaccount

SecuritybasicAuth
Request
query Parameters
name
required
string

The name of the subaccount

Responses
200

Successfully created a subaccount

Response Schema: application/json
object
id
string

The ID of the subaccount

name
string

The name of the subaccount

status
string

The status of the subaccount

Enum: "disabled" "open"
400

Error response

Request samples
Response samples
application/json
{
  • "subaccount": {
    • "id": "123",
    • "name": "My subaccount",
    • "status": "open"
    }
}

Delete a subaccount

delete/v5/accounts/subaccounts

Delete a subaccount

SecuritybasicAuth
Request
header Parameters
X-Mailgun-On-Behalf-Of
required
string

The ID of the subaccount

Responses
200

A 200 response

Response Schema: application/json
message
string

Success message

400

Bad request

403

Forbidden

Request samples
Response samples
application/json
{
  • "message": "Subaccount successfully deleted"
}

Disable a subaccount

post/v5/accounts/subaccounts/{subaccount_id}/disable

Disable a subaccount

SecuritybasicAuth
Request
path Parameters
subaccount_id
required
string

The ID of the subaccount

query Parameters
reason
string

The reason for disabling the subaccount

note
string

A note for the subaccount

Responses
200

Subaccount disabled successfully

Response Schema: application/json
object
id
string

The ID of the subaccount

name
string

The name of the subaccount

status
string

The status of the subaccount

Enum: "disabled" "open"
400

Subaccount is already disabled

404

Not found

Request samples
Response samples
application/json
{
  • "subaccount": {
    • "id": "123",
    • "name": "My subaccount",
    • "status": "disabled"
    }
}

Enable a subaccount

post/v5/accounts/subaccounts/{subaccount_id}/enable

Enable a subaccount

SecuritybasicAuth
Request
path Parameters
subaccount_id
required
string

The ID of the subaccount

Responses
200

Subaccount enabled successfully

Response Schema: application/json
object
id
string

The ID of the subaccount

name
string

The name of the subaccount

status
string

The status of the subaccount

Enum: "disabled" "open"
400

Cannot enable due to limit reached

404

Not found

Request samples
Response samples
application/json
{
  • "subaccount": {
    • "id": "123",
    • "name": "My subaccount",
    • "status": "open"
    }
}