openapi: 3.1.0 info: title: AhaSend API v2 Accounts Routes API description: 'The AhaSend API v2 allows you to send transactional emails, manage domains, webhooks, routes, API keys, and view statistics. ## Authentication All API requests must be authenticated using a Bearer token in the Authorization header: ``` Authorization: Bearer aha-sk-64-CHARACTER-RANDOM-STRING ``` ## Scopes API keys have specific scopes that control access to different resources and actions: ### Message Scopes - `messages:send:all` - Send messages from any domain in the account - `messages:send:{domain}` - Send messages from a specific domain - `messages:cancel:all` - Cancel messages from any domain - `messages:cancel:{domain}` - Cancel messages from a specific domain - `messages:read:all` - Read messages from any domain - `messages:read:{domain}` - Read messages from a specific domain ### Domain Scopes - `domains:read` - Read all domains - `domains:write` - Create and update domains - `domains:delete:all` - Delete any domain - `domains:delete:{domain}` - Delete a specific domain ### Account Scopes - `accounts:read` - Read account information - `accounts:write` - Update account settings - `accounts:billing` - Access billing information - `accounts:members:read` - Read account members - `accounts:members:add` - Add account members - `accounts:members:update` - Update account members - `accounts:members:remove` - Remove account members ### Webhook Scopes - `webhooks:read:all` - Read all webhooks - `webhooks:read:{domain}` - Read webhooks for a specific domain - `webhooks:write:all` - Create and update webhooks - `webhooks:write:{domain}` - Create and update webhooks for a specific domain - `webhooks:delete:all` - Delete any webhook - `webhooks:delete:{domain}` - Delete webhooks for a specific domain ### Route Scopes - `routes:read:all` - Read all routes - `routes:read:{domain}` - Read routes for a specific domain - `routes:write:all` - Create and update routes - `routes:write:{domain}` - Create and update routes for a specific domain - `routes:delete:all` - Delete any route - `routes:delete:{domain}` - Delete routes for a specific domain ### Suppression Scopes - `suppressions:read` - Read suppressions - `suppressions:write` - Create suppressions - `suppressions:delete` - Delete suppressions - `suppressions:wipe` - Delete all suppressions (dangerous) ### SMTP Credentials Scopes - `smtp-credentials:read:all` - Read all SMTP credentials - `smtp-credentials:read:{domain}` - Read SMTP credentials for a specific domain - `smtp-credentials:write:all` - Create SMTP credentials - `smtp-credentials:write:{domain}` - Create SMTP credentials for a specific domain - `smtp-credentials:delete:all` - Delete any SMTP credentials - `smtp-credentials:delete:{domain}` - Delete SMTP credentials for a specific domain ### Statistics Scopes - `statistics-transactional:read:all` - Read all transactional statistics - `statistics-transactional:read:{domain}` - Read transactional statistics for a specific domain ### API Key Scopes - `api-keys:read` - Read API keys - `api-keys:write` - Create and update API keys - `api-keys:delete` - Delete API keys ## Rate Limiting - General API endpoints: 100 requests per second, 200 burst - Statistics endpoints: 1 request per second, 1 burst ## Pagination List endpoints use cursor-based pagination with the following parameters: - `limit`: Maximum number of items to return (default: 100, max: 100) - `cursor`: Pagination cursor for the next page ## Time Formats All timestamps must be in RFC3339 format, e.g., `2023-12-25T10:30:00Z` ## Idempotency POST requests support idempotency through the optional `Idempotency-Key` header. When provided: - The same request can be safely retried multiple times - Duplicate requests return the same response with `Idempotent-Replayed: true` - In-progress requests return HTTP 409 with `Idempotent-Replayed: false` - Failed requests return HTTP 412 with `Idempotent-Replayed: false` - Idempotency keys expire after 24 hours ' version: 2.0.0 contact: email: support@ahasend.com license: name: MIT identifier: MIT servers: - url: https://api.ahasend.com description: Production server security: - BearerAuth: [] tags: - name: Routes description: Manage inbound email routing paths: /v2/accounts/{account_id}/routes: get: summary: AhaSend Get Routes description: Returns a list of routes for the account operationId: getRoutes tags: - Routes parameters: - name: account_id in: path required: true description: Account ID schema: type: string format: uuid example: '500123' - name: limit in: query description: Maximum number of items to return (1-100) schema: type: integer minimum: 1 maximum: 100 default: 100 example: 1 - name: after in: query description: Pagination cursor for the next page. Provide the value provided in `next_cursor` from the response. schema: type: string example: example_value - name: before in: query description: Pagination cursor for the previous page. schema: type: string example: example_value security: - BearerAuth: - routes:read:all - routes:read:{domain} x-code-samples: - lang: go label: AhaSend Go SDK source: "package main\n\nimport (\n \"context\"\n \"fmt\"\n \"log\"\n\n \"github.com/AhaSend/ahasend-go/api\"\n \"github.com/google/uuid\"\n)\n\nfunc main() {\n // Create API client with authentication\n client := api.NewAPIClient(\n api.WithAPIKey(\"aha-sk-your-64-character-key\"),\n )\n\n accountID := uuid.New()\n\n // Create context for the API call\n ctx := context.Background()\n\n // Call the ping endpoint\n response, httpResp, err := client.RoutesAPI.GetRoutes(\n ctx,\n accountID,\n nil,\n nil,\n )\n if err != nil {\n log.Fatalf(\"Error getting routes: %v\", err)\n }\n\n // Check response\n if httpResp.StatusCode == 200 {\n fmt.Printf(\"✅ Status: %d\\n\", httpResp.StatusCode)\n if response != nil {\n fmt.Printf(\"Found %d routes\\n\", len(response.Data))\n }\n } else {\n fmt.Printf(\"❌ Unexpected status code: %d\\n\", httpResp.StatusCode)\n }\n}\n" responses: '200': description: List of routes content: application/json: schema: $ref: '#/components/schemas/PaginatedRoutesResponse' examples: getRoutes200Example: summary: Default getRoutes 200 response x-microcks-default: true value: object: list data: - {} pagination: has_more: {} next_cursor: {} previous_cursor: {} '400': description: Bad request content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: getRoutes400Example: summary: Default getRoutes 400 response x-microcks-default: true value: message: example_value '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: getRoutes401Example: summary: Default getRoutes 401 response x-microcks-default: true value: message: example_value '403': description: Forbidden content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: getRoutes403Example: summary: Default getRoutes 403 response x-microcks-default: true value: message: example_value '500': description: Internal server error content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: getRoutes500Example: summary: Default getRoutes 500 response x-microcks-default: true value: message: example_value x-microcks-operation: delay: 0 dispatcher: FALLBACK post: summary: AhaSend Create Route description: Creates a new route for inbound email routing operationId: createRoute tags: - Routes parameters: - name: account_id in: path required: true description: Account ID schema: type: string format: uuid example: '500123' - $ref: '#/components/parameters/IdempotencyKey' example: example security: - BearerAuth: - routes:write:all - routes:write:{domain} x-code-samples: - lang: go label: AhaSend Go SDK source: "package main\n\nimport (\n \"context\"\n \"fmt\"\n \"log\"\n\n \"github.com/AhaSend/ahasend-go/api\"\n \"github.com/AhaSend/ahasend-go/models/requests\"\n \"github.com/google/uuid\"\n)\n\nfunc main() {\n // Create API client with authentication\n client := api.NewAPIClient(\n api.WithAPIKey(\"aha-sk-your-64-character-key\"),\n )\n\n accountID := uuid.New()\n\n // Create context for the API call\n ctx := context.Background()\n\n // Call the ping endpoint\n response, httpResp, err := client.RoutesAPI.CreateRoute(\n ctx,\n accountID,\n requests.CreateRouteRequest{\n Name: \"My Route\",\n URL: \"https://mystartup.com/tickets\",\n Recipient: \"ticket-*@mystartup.com\",\n Enabled: true,\n Attachments: true,\n Headers: true,\n StripReplies: true,\n },\n )\n if err != nil {\n log.Fatalf(\"Error creating route: %v\", err)\n }\n\n // Check response\n if httpResp.StatusCode == 200 {\n fmt.Printf(\"✅ Status: %d\\n\", httpResp.StatusCode)\n if response != nil {\n fmt.Printf(\"Created route: %#v\\n\", response)\n }\n } else {\n fmt.Printf(\"❌ Unexpected status code: %d\\n\", httpResp.StatusCode)\n }\n}\n" requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/CreateRouteRequest' responses: '201': description: Route created successfully headers: Idempotent-Replayed: $ref: '#/components/headers/IdempotentReplayed' content: application/json: schema: $ref: '#/components/schemas/Route' examples: createRoute201Example: summary: Default createRoute 201 response x-microcks-default: true value: object: route id: '500123' created_at: '2025-03-15T14:30:00Z' updated_at: '2025-03-15T14:30:00Z' name: Example Name '400': description: Bad request content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: createRoute400Example: summary: Default createRoute 400 response x-microcks-default: true value: message: example_value '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: createRoute401Example: summary: Default createRoute 401 response x-microcks-default: true value: message: example_value '403': description: Forbidden content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: createRoute403Example: summary: Default createRoute 403 response x-microcks-default: true value: message: example_value '409': $ref: '#/components/responses/IdempotencyConflict' '412': $ref: '#/components/responses/IdempotencyPreconditionFailed' '500': description: Internal server error content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: createRoute500Example: summary: Default createRoute 500 response x-microcks-default: true value: message: example_value x-microcks-operation: delay: 0 dispatcher: FALLBACK /v2/accounts/{account_id}/routes/{route_id}: get: summary: AhaSend Get Route description: Returns a specific route by ID operationId: getRoute tags: - Routes parameters: - name: account_id in: path required: true description: Account ID schema: type: string format: uuid example: '500123' - name: route_id in: path required: true description: Route ID schema: type: string format: uuid example: '500123' security: - BearerAuth: - routes:read:all - routes:read:{domain} x-code-samples: - lang: go label: AhaSend Go SDK source: "package main\n\nimport (\n \"context\"\n \"fmt\"\n \"log\"\n\n \"github.com/AhaSend/ahasend-go/api\"\n \"github.com/google/uuid\"\n)\n\nfunc main() {\n // Create API client with authentication\n client := api.NewAPIClient(\n api.WithAPIKey(\"aha-sk-your-64-character-key\"),\n )\n\n accountID := uuid.New()\n\n // Create context for the API call\n ctx := context.Background()\n\n // Call the ping endpoint\n response, httpResp, err := client.RoutesAPI.GetRoute(\n ctx,\n accountID,\n uuid.MustParse(\"c5a32c40-b351-439f-8230-779daed3e42c\"),\n )\n if err != nil {\n log.Fatalf(\"Error getting route: %v\", err)\n }\n\n // Check response\n if httpResp.StatusCode == 200 {\n fmt.Printf(\"✅ Status: %d\\n\", httpResp.StatusCode)\n if response != nil {\n fmt.Printf(\"Route: %#v\\n\", response)\n }\n } else {\n fmt.Printf(\"❌ Unexpected status code: %d\\n\", httpResp.StatusCode)\n }\n}\n" responses: '200': description: Route details content: application/json: schema: $ref: '#/components/schemas/Route' examples: getRoute200Example: summary: Default getRoute 200 response x-microcks-default: true value: object: route id: '500123' created_at: '2025-03-15T14:30:00Z' updated_at: '2025-03-15T14:30:00Z' name: Example Name '400': description: Bad request content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: getRoute400Example: summary: Default getRoute 400 response x-microcks-default: true value: message: example_value '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: getRoute401Example: summary: Default getRoute 401 response x-microcks-default: true value: message: example_value '403': description: Forbidden content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: getRoute403Example: summary: Default getRoute 403 response x-microcks-default: true value: message: example_value '404': description: Route not found content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: getRoute404Example: summary: Default getRoute 404 response x-microcks-default: true value: message: example_value '500': description: Internal server error content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: getRoute500Example: summary: Default getRoute 500 response x-microcks-default: true value: message: example_value x-microcks-operation: delay: 0 dispatcher: FALLBACK put: summary: AhaSend Update Route description: Updates an existing route operationId: updateRoute tags: - Routes parameters: - name: account_id in: path required: true description: Account ID schema: type: string format: uuid example: '500123' - name: route_id in: path required: true description: Route ID schema: type: string format: uuid example: '500123' security: - BearerAuth: - routes:write:all - routes:write:{domain} x-code-samples: - lang: go label: AhaSend Go SDK source: "package main\n\nimport (\n \"context\"\n \"fmt\"\n \"log\"\n\n \"github.com/AhaSend/ahasend-go\"\n \"github.com/AhaSend/ahasend-go/api\"\n \"github.com/AhaSend/ahasend-go/models/requests\"\n \"github.com/google/uuid\"\n)\n\nfunc main() {\n // Create API client with authentication\n client := api.NewAPIClient(\n api.WithAPIKey(\"aha-sk-your-64-character-key\"),\n )\n\n accountID := uuid.New()\n\n // Create context for the API call\n ctx := context.Background()\n\n // Call the ping endpoint\n response, httpResp, err := client.RoutesAPI.UpdateRoute(\n ctx,\n accountID,\n uuid.MustParse(\"c5a32c40-b351-439f-8230-779daed3e42c\"),\n requests.UpdateRouteRequest{\n Name: ahasend.String(\"Updated Name\"),\n URL: ahasend.String(\"https://mystartup.com/new-tickets\"),\n },\n )\n if err != nil {\n log.Fatalf(\"Error updating route: %v\", err)\n }\n\n // Check response\n if httpResp.StatusCode == 200 {\n fmt.Printf(\"✅ Status: %d\\n\", httpResp.StatusCode)\n if response != nil {\n fmt.Printf(\"Updated route: %#v\\n\", response)\n }\n } else {\n fmt.Printf(\"❌ Unexpected status code: %d\\n\", httpResp.StatusCode)\n }\n}\n" requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/UpdateRouteRequest' responses: '200': description: Route updated successfully content: application/json: schema: $ref: '#/components/schemas/Route' examples: updateRoute200Example: summary: Default updateRoute 200 response x-microcks-default: true value: object: route id: '500123' created_at: '2025-03-15T14:30:00Z' updated_at: '2025-03-15T14:30:00Z' name: Example Name '400': description: Bad request content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: updateRoute400Example: summary: Default updateRoute 400 response x-microcks-default: true value: message: example_value '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: updateRoute401Example: summary: Default updateRoute 401 response x-microcks-default: true value: message: example_value '403': description: Forbidden content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: updateRoute403Example: summary: Default updateRoute 403 response x-microcks-default: true value: message: example_value '404': description: Route not found content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: updateRoute404Example: summary: Default updateRoute 404 response x-microcks-default: true value: message: example_value '500': description: Internal server error content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: updateRoute500Example: summary: Default updateRoute 500 response x-microcks-default: true value: message: example_value x-microcks-operation: delay: 0 dispatcher: FALLBACK delete: summary: AhaSend Delete Route description: Deletes a route operationId: deleteRoute tags: - Routes parameters: - name: account_id in: path required: true description: Account ID schema: type: string format: uuid example: '500123' - name: route_id in: path required: true description: Route ID schema: type: string format: uuid example: '500123' security: - BearerAuth: - routes:delete:all - routes:delete:{domain} x-code-samples: - lang: go label: AhaSend Go SDK source: "package main\n\nimport (\n \"context\"\n \"fmt\"\n \"log\"\n\n \"github.com/AhaSend/ahasend-go/api\"\n \"github.com/google/uuid\"\n)\n\nfunc main() {\n // Create API client with authentication\n client := api.NewAPIClient(\n api.WithAPIKey(\"aha-sk-your-64-character-key\"),\n )\n\n accountID := uuid.New()\n\n // Create context for the API call\n ctx := context.Background()\n\n // Call the ping endpoint\n response, httpResp, err := client.RoutesAPI.DeleteRoute(\n ctx,\n accountID,\n uuid.MustParse(\"c5a32c40-b351-439f-8230-779daed3e42c\"),\n )\n if err != nil {\n log.Fatalf(\"Error deleting route: %v\", err)\n }\n\n // Check response\n if httpResp.StatusCode == 200 {\n fmt.Printf(\"✅ Status: %d\\n\", httpResp.StatusCode)\n if response != nil {\n fmt.Printf(\"Deleted route: %#v\\n\", response)\n }\n } else {\n fmt.Printf(\"❌ Unexpected status code: %d\\n\", httpResp.StatusCode)\n }\n}\n" responses: '200': description: Route deleted successfully content: application/json: schema: $ref: '#/components/schemas/SuccessResponse' examples: deleteRoute200Example: summary: Default deleteRoute 200 response x-microcks-default: true value: message: example_value '400': description: Bad request content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: deleteRoute400Example: summary: Default deleteRoute 400 response x-microcks-default: true value: message: example_value '401': description: Unauthorized content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: deleteRoute401Example: summary: Default deleteRoute 401 response x-microcks-default: true value: message: example_value '403': description: Forbidden content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: deleteRoute403Example: summary: Default deleteRoute 403 response x-microcks-default: true value: message: example_value '404': description: Route not found content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: deleteRoute404Example: summary: Default deleteRoute 404 response x-microcks-default: true value: message: example_value '500': description: Internal server error content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: deleteRoute500Example: summary: Default deleteRoute 500 response x-microcks-default: true value: message: example_value x-microcks-operation: delay: 0 dispatcher: FALLBACK components: responses: IdempotencyConflict: description: Request in progress - a request with this idempotency key is already being processed headers: Idempotent-Replayed: $ref: '#/components/headers/IdempotentReplayed' content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' example: message: A request with this idempotency key is already in progress IdempotencyPreconditionFailed: description: Original request failed - the request with this idempotency key previously failed and cannot be retried headers: Idempotent-Replayed: $ref: '#/components/headers/IdempotentReplayed' content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' example: message: The original request with this idempotency key failed and cannot be retried schemas: ErrorResponse: type: object required: - message properties: message: type: string description: Error description example: example_value example: message: Error message UpdateRouteRequest: type: object properties: name: type: string maxLength: 255 nullable: true description: Route name example: Example Name url: type: string format: uri nullable: true description: Webhook URL for the route example: https://example.com recipient: type: string maxLength: 255 nullable: true description: Recipient filter example: example_value attachments: type: boolean nullable: true description: Whether to include attachments in webhooks example: true headers: type: boolean nullable: true description: Whether to include headers in webhooks example: true group_by_message_id: type: boolean nullable: true description: Whether to group by message ID example: true strip_replies: type: boolean nullable: true description: Whether to strip reply content example: true enabled: type: boolean nullable: true description: Whether the route is enabled example: true example: name: Updated Support Route enabled: false Route: type: object properties: object: type: string enum: - route description: Object type identifier example: route id: type: string format: uuid description: Unique identifier for the route example: '500123' created_at: type: string format: date-time description: When the route was created example: '2025-03-15T14:30:00Z' updated_at: type: string format: date-time description: When the route was last updated example: '2025-03-15T14:30:00Z' name: type: string description: Route name example: Example Name url: type: string format: uri description: Webhook URL for the route example: https://example.com recipient: type: string nullable: true description: Recipient filter example: example_value attachments: type: boolean description: Whether to include attachments in route payload example: true headers: type: boolean description: Whether to include headers in route payload example: true group_by_message_id: type: boolean description: Whether to group by message ID example: true strip_replies: type: boolean description: Whether to strip reply content example: true enabled: type: boolean description: Whether the route is enabled example: true success_count: type: integer description: Number of successful calls example: 1 error_count: type: integer description: Number of unsuccessful calls example: 1 errors_since_last_success: type: integer description: Number of consecutive failed calls example: 1 last_request_at: type: string format: date-time description: When the route was last called example: '2025-03-15T14:30:00Z' required: - object - id - created_at - updated_at - name - url - enabled CreateRouteRequest: type: object required: - name - url properties: name: type: string maxLength: 255 description: Route name example: Example Name url: type: string format: uri description: Webhook URL for the route example: https://example.com recipient: type: string maxLength: 255 description: Recipient filter example: example_value attachments: type: boolean description: Whether to include attachments in webhooks default: false example: true headers: type: boolean description: Whether to include headers in webhooks default: false example: true group_by_message_id: type: boolean description: Whether to group by message ID default: false example: true strip_replies: type: boolean description: Whether to strip reply content default: false example: true enabled: type: boolean description: Whether the route is enabled default: true example: true example: name: Support Route url: https://example.com/webhook enabled: true PaginatedRoutesResponse: type: object required: - object - data - pagination properties: object: type: string enum: - list description: Object type identifier example: list data: type: array items: $ref: '#/components/schemas/Route' description: Array of routes example: - object: route id: '500123' created_at: '2025-03-15T14:30:00Z' updated_at: '2025-03-15T14:30:00Z' name: Example Name pagination: $ref: '#/components/schemas/PaginationInfo' SuccessResponse: type: object required: - message properties: message: type: string description: Success message example: example_value example: message: Operation completed successfully PaginationInfo: type: object required: - has_more properties: has_more: type: boolean description: Whether there are more items available example: true next_cursor: type: string description: Cursor for the next page of results example: example_value previous_cursor: type: string description: Cursor for the previous page of results example: example_value example: has_more: true next_cursor: eyJpZCI6MTIzNH0= parameters: IdempotencyKey: name: Idempotency-Key in: header required: false description: 'Optional idempotency key for safe request retries. Must be a unique string for each logical request. Requests with the same key will return the same response. Keys expire after 24 hours. ' schema: type: string maxLength: 255 example: user-12345-create-domain-20240101 headers: IdempotentReplayed: description: 'Indicates whether this response is replayed from a previous identical request. - `true`: Response was replayed from cache (duplicate request) - `false`: Response from original processing or error state ' schema: type: string enum: - true - false securitySchemes: BearerAuth: type: http scheme: bearer bearerFormat: aha-sk-64-CHARACTER-RANDOM-STRING description: API key for authentication