# Send a sample event

`POST https://api.morevoice.ai/v1/test_helpers/events`

Test mode only. Emits one sample event of `type`: it is stored and delivered to your test-mode webhook endpoints that subscribe to it, signed and retried like any event.

Authenticate with a secret API key: `Authorization: Bearer $MOREVOICE_API_KEY`.

Operation ID: `test_helpers_events_create`.

## Parameters

### Headers

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `MoreVoice-Version` | `string` | no | The API version to use for this request. Defaults to the version the API key is pinned to. |
| `Idempotency-Key` | `string` | no | A unique key (for example a UUID) that makes this request safe to retry: for 24 hours, a retry with the same key and parameters returns the first response instead of acting twice. |

## Request body

Required, `application/json`.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | `string` | yes | An event type from the catalogue, e.g. `call.ended`. |

Example:

```json
{
  "type": "call.ended"
}
```

## Responses

### 201 Created

Created Returns `TestHelperEvent`.

| Field | Type | Description |
| --- | --- | --- |
| `object` | `"test_event"` | — |
| `id` | `string` | The event's ID: it is stored and delivered like any event. |
| `type` | `string` | — |
| `livemode` | `boolean` | `true` in live mode, `false` in test mode. |

Example:

```json
{
  "id": "evt_7Yb2Qx9LmN4tV8wK1cY0bZ",
  "livemode": false,
  "object": "test_event",
  "type": "call.ended"
}
```

### 400 Bad Request

The request is invalid: a parameter is missing, malformed or unknown, or the version header is unknown. Returns `ErrorEnvelope`.

### 401 Unauthorized

No valid API key was sent. Returns `ErrorEnvelope`.

### 403 Forbidden

The key may not do this (a missing scope, a plan limit, or a compliance block). Returns `ErrorEnvelope`.

### 409 Conflict

The request conflicts with the object's state, or the Idempotency-Key was reused with other parameters. Returns `ErrorEnvelope`.

### 429 Too Many Requests

Too many requests, or no call capacity right now. Retry after the Retry-After delay. Returns `ErrorEnvelope`.

### 500 Internal Server Error

Something went wrong on MoreVoice's side. Retry with the same Idempotency-Key. Returns `ErrorEnvelope`.

## Code samples

**TypeScript**

```ts
import MoreVoice from "@morevoice/sdk";

const mv = new MoreVoice(); // MOREVOICE_API_KEY from the environment

const testHelperEvent = await mv.testHelpersEvents.create({
	type: "call.ended",
});
console.log(testHelperEvent);
```

**Python**

```python
from morevoice import MoreVoice

client = MoreVoice()  # MOREVOICE_API_KEY from the environment

test_helper_event = client.test_helpers_events.create({
    "type": "call.ended",
})
print(test_helper_event)
```

**cURL**

```sh
curl -X POST https://api.morevoice.ai/v1/test_helpers/events \
  -H "Authorization: Bearer $MOREVOICE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
  "type": "call.ended"
}'
```
