# Set an event-to-workflow mapping for automatic workflow triggers

`POST /api/integration/sim/events/mappings`

Authentication (security requirement alternatives):

```json
[
  {
    "bearer": []
  }
]
```

- bearer: http (bearer), header JWT. Enter JWT token

Request body: application/json (required)

Type: object

Schema: [EventMappingDto](https://sourcey-gauzy.pages.dev/api-reference/models/eventmappingdto/index.md)

- `event` (required)
  Type: string
  
  The Gauzy event type to map
  
  enum: ["timer.started","timer.stopped","timer.status_updated","task.created","task.updated","task.deleted","screenshot.created","screenshot.updated","screenshot.deleted","integration.created","integration.updated","integration.deleted","account.registered","account.verified"]

- `workflowId` (required)
  Type: string
  
  The SIM workflow ID to trigger when this event fires

Responses:

- 200: Event mapping saved

- 404: SIM integration not found

## Examples

### cURL

```bash
curl -X POST 'http://localhost:3000/api/integration/sim/events/mappings' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "event": "timer.started",
  "workflowId": "string"
}'
```

### JavaScript

```javascript
const body = `{
  "event": "timer.started",
  "workflowId": "string"
}`;

const response = await fetch('http://localhost:3000/api/integration/sim/events/mappings', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_TOKEN',
    'Content-Type': 'application/json',
  },
  body,
});

const data = await response.text();
```

### Python

```python
import requests

body = '''{
  "event": "timer.started",
  "workflowId": "string"
}'''

response = requests.post(
    'http://localhost:3000/api/integration/sim/events/mappings',
    data=body.encode('utf-8'),
    headers={
        'Authorization': 'Bearer YOUR_TOKEN',
        'Content-Type': 'application/json',
    },
)
print(response.text)
```
