Documentation for aampe events endpoint

Overview

The Aampe Webhook allows clients to send events to our system. Each event must contain specific information about the user and the event itself. This document describes the API endpoint, request format, and response details.

API Endpoint

HOST https://ingestion.api.aampe.com

ROUTE /v1/events

Description

This endpoint handles events coming from an Aampe Webhook.

Request Headers

  • Authorization (required): A valid API key in the format Bearer <token>

Request Body

The payload for this endpoint should be a JSON object with the following structure:

FieldRequiredDescription
contact_idYesThe unique ID of the user triggering the event.
event_nameYesThe name of the event that took place.
timestampYesUnix timestamp representing when the event occurred.
event_idNoOptional unique ID of the event. Defaults to a UUID if not provided.
metadataNoOptional JSON object representing any extra metadata associated with the event.

Example Request Payload

{
  "contact_id": "user123",
  "event_name": "login",
  "time": 1672531200,
  "event_id": "e3b0c442-98fc-4e4e-a83f-5f7d7edc2f38",
  "metadata": {
    "platform": "web",
    "browser": "Chrome"
  }
}

Response

  • Status Code:
    • 200 OK: The event was successfully received and processed.
    • 401 UNAUTHORIZED: The provided API key is invalid or missing.
    • 422 UNPROCESSABLE ENTITY: The request payload is invalid. The error response will contain details about the specific validation issues.

Successful Response

Status Code:

202 Accepted

If the event is successfully processed, the server will respond with a 202 Accepted status code, indicating that the event has been accepted and is being processed asynchronously.

Error Responses

401 Unauthorized

Reason: Missing or invalid API key in the Authorization header.

{  
  "detail": "Invalid API Key"  
}

422 Unprocessable Entity

Reason: Validation error in the request body. This error occurs if the JSON payload does not conform to the expected schema.

Response Format:

{  
  "detail": [  
    {  
      "loc": ["body", "field_name"],  
      "msg": "error message describing the issue",  
      "type": "error_type"  
    }  
  ]  
}

Notes

  • Ensure that the Authorization header is included with a valid JWT token for the request to be processed.
  • The metadata field is optional, but if included, it must be a valid JSON object.