Skip to content

Documentation navigation

API Keys and Webhooks

Create and rotate API keys, configure webhooks, and diagnose failed deliveries.

#API Keys and Webhooks

API keys are the credentials your software uses to talk to mAIvn, and webhooks are how mAIvn talks back to your software when something happens. This guide covers both: creating and safeguarding keys, and setting up webhook endpoints to receive event callbacks, all from the portal.

See also: Authentication & API Keys — how to use a key from the SDK (api_key / Client), key scopes, and handling rejected keys in Python.

#API Keys

Use API keys when your application needs server-to-server access. Each key is restricted to its project. Fine-grained key permission levels are not available, so the Scope column in the portal always reads Project.

#Key lifecycle

  1. Open the project's API keys tab and create a key with a descriptive name. You can set an expiry date.
  2. Copy the plaintext key immediately. It is shown once, and mAIvn stores only a hash. Keys start with mvn_v2_.
  3. Store it in a secret manager and pass it to your application as MAIVN_API_KEY.
  4. To rotate, create a replacement key, deploy it, then revoke the old one. There is no in-place rotate button for API keys.

The table lists each key's name, prefix (the first 12 characters, shown with ...****), status, last use, expiry and creation date. You can search by name or prefix and filter by active or revoked. To revoke a key, type its name to confirm.

Revocation takes effect everywhere within 30 seconds. A key also stops working when the person who created it is no longer a member of the team or the project, and while its team is suspended.

#Who can do what

Any member of the team or the project can see the key list. Creating and revoking keys needs the team or project role owner or admin. The person who created the project keeps that right while they remain a member.

Project API keys table with a masked example key

Current Portal interface with sample data. The masked prefix shown here is not a usable credential.

#Webhooks

Webhooks let your systems receive event callbacks from the platform. Open the project's Webhooks tab to add one.

Each webhook has:

  • An endpoint URL
  • A list of event types, matched exactly. The portal requires at least one and suggests session.completed. There are no wildcards.
  • An active switch
  • A consecutive-failure counter

Creating a webhook shows its signing secret once. It starts with whsec_. Rotate the secret from the webhook's row when you need a new one. The previous secret stops working at once, so deploy the new one to your receiver immediately. Creating, editing, rotating and deleting webhooks needs the team or project role owner or admin.

#What mAIvn sends

mAIvn POSTs JSON to your URL. The body holds organization_id, project_id and an event object. Each request carries these headers:

HeaderValue
X-Maivn-Signaturet=<unix seconds>,v1=<hex HMAC-SHA256>
X-Maivn-Subscription-IDThe webhook's ID
X-Maivn-Secret-VersionWhich version of the signing secret signed the request
User-AgentMAIVN-Webhooks/2.0

The signature is an HMAC-SHA256 over <timestamp>.<raw request body>, keyed with the full secret string including the whsec_ prefix. Verify it against the raw bytes before you parse the JSON:

Python
import hashlib
import hmac
import time


def verify_maivn_signature(
    secret: str, body: bytes, header: str, tolerance_seconds: int = 300
) -> bool:
    parts = dict(item.split("=", 1) for item in header.split(",") if "=" in item)
    timestamp, received = parts.get("t"), parts.get("v1")
    if not timestamp or not received:
        return False
    try:
        age = abs(time.time() - int(timestamp))
    except ValueError:
        return False
    if age > tolerance_seconds:
        return False
    expected = hmac.new(
        secret.encode(), f"{timestamp}.".encode() + body, hashlib.sha256
    ).hexdigest()
    return hmac.compare_digest(received, expected)

The timestamp check is your replay guard. mAIvn does not set a tolerance for you, so pick one.

#Delivery rules

  • Return a 2xx within 10 seconds. Any other status, or no answer, counts as a failed attempt.
  • Each delivery gets up to four attempts, waiting 1, 5 and 30 seconds between them. A delivery that fails all four counts as one failure against the webhook.
  • Redirects are not followed. A redirect fails the delivery without a retry.
  • The URL must use http or https on the default port (80 or 443), carry no credentials, and resolve to a public address. Localhost, private ranges and link-local addresses are refused, so a receiver on your laptop needs a public URL in front of it.
  • By default a webhook is disabled after 10 consecutive failed deliveries. A success resets the counter. Turn the row's active switch back on once the receiver is fixed.

#Reliability checklist

  • Return a 2xx quickly and do the work afterwards.
  • Verify the signature and timestamp before processing.
  • Treat deliveries as at-least-once. A retry can repeat an event, so dedupe on the event_id inside the event object.
  • Watch the failure badge on the webhook row, and use its delivery view to inspect recent attempts.

#Security Checklist

  • Never embed API keys in frontend code.
  • Use separate project keys for workloads that need separate access or revocation.
  • Rotate keys on a schedule and after any incident.
  • Use HTTPS-only webhook endpoints.

#Next steps