> ## Documentation Index
> Fetch the complete documentation index at: https://docs.autosend.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Send Event

> Records an event log for a contact. The eventName must match an existing event definition; properties are validated and coerced against the declared schema.

> [!NOTE]
>
> Records an event log for a contact. The `eventName` must match an existing event definition; supplied `eventProperties` are validated and coerced against the declared property schema. Either `email` or `contactId` is required to identify the contact.

> [!NOTE]
>
> Triggering an event also evaluates any active workflow automations whose entry criteria match this event name. The workflow evaluation is fire-and-forget — it never blocks the API response.

```bash cURL theme={null}
curl --request POST \
  --url https://api.autosend.com/v1/events/send \
  --header 'Authorization: Bearer AS_your-project-api-key' \
  --header 'Content-Type: application/json' \
  --data '{
  "eventName": "order_completed",
  "email": "jane@example.com",
  "eventProperties": {
    "order_total": 129.99,
    "currency": "USD",
    "is_first_purchase": true
  }
}'
```

```python Python theme={null}
import requests

url = "https://api.autosend.com/v1/events/send"

headers = {
    "Authorization": "Bearer AS_your-project-api-key",
    "Content-Type": "application/json"
}

payload = {
    "eventName": "order_completed",
    "email": "jane@example.com",
    "eventProperties": {
        "order_total": 129.99,
        "currency": "USD",
        "is_first_purchase": True
    }
}

response = requests.post(url, json=payload, headers=headers)
print(response.json())
```

```javascript JavaScript theme={null}
fetch('https://api.autosend.com/v1/events/send', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer AS_your-project-api-key',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    eventName: 'order_completed',
    email: 'jane@example.com',
    eventProperties: {
      order_total: 129.99,
      currency: 'USD',
      is_first_purchase: true
    }
  })
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));
```

```php PHP theme={null}
<?php

$url = 'https://api.autosend.com/v1/events/send';

$data = [
    'eventName' => 'order_completed',
    'email' => 'jane@example.com',
    'eventProperties' => [
        'order_total' => 129.99,
        'currency' => 'USD',
        'is_first_purchase' => true
    ]
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer AS_your-project-api-key',
    'Content-Type: application/json'
]);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
?>
```

```go Go theme={null}
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io"
    "net/http"
)

func main() {
    url := "https://api.autosend.com/v1/events/send"

    payload := map[string]interface{}{
        "eventName": "order_completed",
        "email":     "jane@example.com",
        "eventProperties": map[string]interface{}{
            "order_total":       129.99,
            "currency":          "USD",
            "is_first_purchase": true,
        },
    }

    jsonData, _ := json.Marshal(payload)

    req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
    req.Header.Set("Authorization", "Bearer AS_your-project-api-key")
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        fmt.Println("Error:", err)
        return
    }
    defer resp.Body.Close()

    body, _ := io.ReadAll(resp.Body)
    fmt.Println(string(body))
}
```

```java Java theme={null}
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;

public class SendEvent {
    public static void main(String[] args) {
        try {
            URL url = new URL("https://api.autosend.com/v1/events/send");
            HttpURLConnection con = (HttpURLConnection) url.openConnection();

            con.setRequestMethod("POST");
            con.setRequestProperty("Authorization", "Bearer AS_your-project-api-key");
            con.setRequestProperty("Content-Type", "application/json");
            con.setDoOutput(true);

            String jsonInputString = "{\n" +
                "  \"eventName\": \"order_completed\",\n" +
                "  \"email\": \"jane@example.com\",\n" +
                "  \"eventProperties\": {\n" +
                "    \"order_total\": 129.99,\n" +
                "    \"currency\": \"USD\",\n" +
                "    \"is_first_purchase\": true\n" +
                "  }\n" +
                "}";

            try (OutputStream os = con.getOutputStream()) {
                byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
                os.write(input, 0, input.length);
            }

            int status = con.getResponseCode();
            System.out.println("Response Status: " + status);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
```

```ruby Ruby theme={null}
require 'net/http'
require 'json'
require 'uri'

uri = URI('https://api.autosend.com/v1/events/send')

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

request = Net::HTTP::Post.new(uri.path)
request['Authorization'] = 'Bearer AS_your-project-api-key'
request['Content-Type'] = 'application/json'

request.body = {
  eventName: 'order_completed',
  email: 'jane@example.com',
  eventProperties: {
    order_total: 129.99,
    currency: 'USD',
    is_first_purchase: true
  }
}.to_json

response = http.request(request)
puts response.body
```

```json 201 Response theme={null}
{
  "success": true,
  "data": {
    "id": "60d5ec49f1b2c72d9c8b9999",
    "eventName": "order_completed",
    "contactId": "60d5ec49f1b2c72d9c8b8888",
    "properties": {
      "order_total": 129.99,
      "currency": "USD",
      "is_first_purchase": true
    },
    "createdAt": "2026-05-08T13:45:00.000Z"
  }
}
```

***

#### Authorizations

**Authorizations** `string | header` *required*

Project API key header of the form Bearer `AS_<key>`.

### Body

**eventName** `string` *required*

Name of an existing event definition for this project.

Example: `"order_completed"`

> [!NOTE]
>
> You must provide either `email` or `contactId` to identify the contact. Providing both is allowed - `contactId` takes precedence.

**email** `string`

Email address of the contact this event belongs to. You should send either `contactId` or `email` . Alternatively you can send both and in this case, `contactId` will take precedence.  If there is no contact with the provided email present in your contact list, a new contact will be created with this emailId and event.

Example: `"jane@example.com"`

**contactId** `string`

ID of the contact this event belongs to.

Example: `"60d5ec49f1b2c72d9c8b8888"`

**eventProperties** `object`

Key/value map of property values. Each key must match a `propertyName` declared on the event definition; values are coerced to the declared `type` (string, number, date, or boolean). Unknown properties are rejected.

Example: `{ "order_total": 129.99, "currency": "USD" }`

#### Response

Event recorded (201)

**success** `boolean`

Example: `true`

**data** `object`

The recorded event log

**child attributes**

**data.id** `string`

Unique event log identifier

**data.eventName** `string`

Event name

**data.contactId** `string`

Contact this event was recorded against

**data.properties** `object`

Coerced event property values

**data.createdAt** `string`

ISO 8601 timestamp the event was recorded at

#### Error Responses

**400 - Missing identifier** `object`

Returned when neither `email` nor `contactId` is provided.

```json theme={null}
{
  "success": false,
  "error": {
    "message": "Either email or contactId is required",
    "code": "EMAIL_OR_CONTACT_ID_REQUIRED"
  }
}
```

**404 - Contact not found** `object`

```json theme={null}
{
  "success": false,
  "error": {
    "message": "Contact not found for the provided email or contactId",
    "code": "CONTACT_NOT_FOUND_FOR_EVENT"
  }
}
```

**404 - Event not found** `object`

```json theme={null}
{
  "success": false,
  "error": {
    "message": "Event not found",
    "code": "EVENT_NOT_FOUND"
  }
}
```

**400 - Unknown property** `object`

Returned when `eventProperties` contains a key not declared on the event definition.

```json theme={null}
{
  "success": false,
  "error": {
    "message": "Property \"foo\" is not declared on event \"order_completed\"",
    "code": "UNKNOWN_PROPERTY"
  }
}
```

**400 - Invalid property value** `object`

Returned when a property value cannot be coerced to its declared type.

```json theme={null}
{
  "success": false,
  "error": {
    "message": "Property \"order_total\" must be a number",
    "code": "INVALID_PROPERTY_VALUE"
  }
}
```


## OpenAPI

````yaml POST /events/send
openapi: 3.1.0
info:
  title: AutoSend API
  description: >-
    AutoSend REST API for managing event definitions and recording event logs
    for a project. These endpoints accept a standard project API key (AS_
    prefix).
  version: 1.0.0
servers:
  - url: https://api.autosend.com/v1
security:
  - bearerAuth: []
paths:
  /events/send:
    post:
      summary: Send Event
      description: >-
        Records an event log for a contact. The eventName must match an existing
        event definition; properties are validated and coerced against the
        declared schema.
components: {}

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.