Skip to Content
Fluxmail

POST /api/v1/admin/api-keys

Create an API key and return its plaintext secret once. A key you create for another member reaches only mailboxes you both can read. Requires admin.api_keys.

Create an API key and return its plaintext secret once. A key you create for another member reaches only mailboxes you both can read. Requires admin.api_keys.

Authentication

Pass an administrator member session or an API key as a bearer token. The key must belong to an administrator and include the capability listed above.

Remote administrative requests require HTTPS. Requests from the local computer can use HTTP.

Request

curl 'http://localhost:8977/api/v1/admin/api-keys' \
  -X POST \
  -H "Authorization: Bearer $FLUXMAIL_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{
  "name": "reporting",
  "member": "you@example.com",
  "permissionProfile": "read-only"
}'

Request body

Content type: application/json

{
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "member": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200
    },
    "accounts": {
      "type": "array",
      "nullable": true,
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 200
      },
      "maxItems": 100
    },
    "permissionProfile": {
      "type": "string",
      "enum": [
        "read-only",
        "read-write",
        "full"
      ]
    },
    "supplementalCapabilities": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "admin.accounts",
          "admin.members",
          "admin.api_keys",
          "admin.license",
          "admin.audit"
        ]
      },
      "maxItems": 5
    },
    "customCapabilities": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "mail.read",
          "mail.drafts",
          "mail.organize",
          "mail.trash",
          "mail.delete",
          "mail.send",
          "admin.accounts",
          "admin.members",
          "admin.api_keys",
          "admin.license",
          "admin.audit"
        ]
      },
      "minItems": 1,
      "maxItems": 11
    }
  },
  "required": [
    "name",
    "member"
  ],
  "additionalProperties": false,
  "example": {
    "name": "reporting",
    "member": "you@example.com",
    "permissionProfile": "read-only"
  }
}

Responses

StatusDescriptionContent type
201Created API key with one-time plaintext secretapplication/json
400Invalid requestapplication/json
401Authentication requiredapplication/json
403Administrative access deniedapplication/json
404Resource not foundapplication/json
409Request conflictapplication/json
413Request body too largeapplication/json
415Unsupported media typeapplication/json
500Internal errorapplication/json
502License could not be verifiedapplication/json

201 response

{
  "type": "object",
  "properties": {
    "data": {
      "allOf": [
        {
          "type": "object",
          "properties": {
            "id": {
              "type": "string"
            },
            "name": {
              "type": "string"
            },
            "createdAt": {
              "type": "string"
            },
            "lastUsedAt": {
              "type": "string",
              "nullable": true
            },
            "memberId": {
              "type": "string"
            },
            "permissionProfile": {
              "type": "string",
              "enum": [
                "read-only",
                "read-write",
                "full",
                "custom"
              ]
            },
            "capabilities": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "mail.read",
                  "mail.drafts",
                  "mail.organize",
                  "mail.trash",
                  "mail.delete",
                  "mail.send",
                  "admin.accounts",
                  "admin.members",
                  "admin.api_keys",
                  "admin.license",
                  "admin.audit"
                ]
              }
            },
            "supplementalCapabilities": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "admin.accounts",
                  "admin.members",
                  "admin.api_keys",
                  "admin.license",
                  "admin.audit"
                ]
              }
            },
            "accountIds": {
              "type": "array",
              "nullable": true,
              "items": {
                "type": "string"
              }
            },
            "issuedByMemberId": {
              "type": "string",
              "nullable": true
            },
            "issuedByEmail": {
              "type": "string",
              "nullable": true
            },
            "issuedByStatus": {
              "type": "string",
              "nullable": true,
              "enum": [
                "pending",
                "active",
                "suspended",
                null
              ]
            }
          },
          "required": [
            "id",
            "name",
            "createdAt",
            "lastUsedAt",
            "memberId",
            "permissionProfile",
            "capabilities",
            "supplementalCapabilities",
            "accountIds",
            "issuedByMemberId",
            "issuedByEmail",
            "issuedByStatus"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "key": {
              "type": "string"
            }
          },
          "required": [
            "key"
          ],
          "additionalProperties": false
        }
      ]
    }
  },
  "required": [
    "data"
  ],
  "additionalProperties": false
}

Last updated