---
title: "Create or replace a trigger"
url: https://hexelstudio.com/docs/api/harness/triggers/create-or-replace-a-trigger
---

# Create or replace a trigger

**PUT** `/harness/triggers/{name}`

Its tasks are created as the caller, who must be able to create tasks here.

## Headers

- `Authorization: string`

  `Bearer <token>`. A Hexel Studio access token for your organization.

- `X-Workspace-Id: string`

  The workspace the request acts in (`ws_...`). It never grants access by itself.

- `X-Environment-Id: string`

  The environment the request acts in (`env_...`). It never grants access by itself.

## Body parameters

- `agent: string`

- `goal: string`

- `inputs: optional object`

- `description: optional string`

- `schedule: optional object`

  - `cron: optional string`

  - `timezone: optional string`

  - `run_once_at: optional string`

## Returns

`200` Replaced. (`Trigger`)

- `created_at: string`

- `created_by: string`

- `environment_id: string`

- `name: string`

- `paused_reason: optional string`

- `routine_error: optional string`

- `routine_id: string`

- `schedules: optional array of RoutineTrigger`

  - `config: any`

    Any JSON value.

  - `id: string`

  - `kind: string`

  - `next_fire_at: optional string`

  - `state: string`

- `state: optional string`

- `target: optional any`

  Any JSON value.

- `updated_at: string`

- `workspace_id: string`

## Errors

- `default` 

## Example

```bash
curl --request PUT \
  --url 'https://api.hexelstudio.com/v1/harness/triggers/{name}' \
  --header "Authorization: Bearer $ACCESS_TOKEN" \
  --header 'X-Workspace-Id: X_WORKSPACE_ID' \
  --header 'X-Environment-Id: X_ENVIRONMENT_ID' \
  --header 'Content-Type: application/json' \
  --data '{
  "agent": "string",
  "goal": "string",
  "inputs": {},
  "description": "string",
  "schedule": {
    "cron": "string",
    "timezone": "string",
    "run_once_at": "2026-01-01T00:00:00Z"
  }
}'
```

### Response (200)

```json
{
  "created_at": "2026-01-01T00:00:00Z",
  "created_by": "string",
  "environment_id": "string",
  "name": "string",
  "paused_reason": "string",
  "routine_error": "string",
  "routine_id": "string",
  "schedules": [
    {
      "config": "string",
      "id": "string",
      "kind": "string",
      "next_fire_at": "2026-01-01T00:00:00Z",
      "state": "string"
    }
  ],
  "state": "string",
  "target": "string",
  "updated_at": "2026-01-01T00:00:00Z",
  "workspace_id": "string"
}
```

### Response (201)

```json
{
  "created_at": "2026-01-01T00:00:00Z",
  "created_by": "string",
  "environment_id": "string",
  "name": "string",
  "paused_reason": "string",
  "routine_error": "string",
  "routine_id": "string",
  "schedules": [
    {
      "config": "string",
      "id": "string",
      "kind": "string",
      "next_fire_at": "2026-01-01T00:00:00Z",
      "state": "string"
    }
  ],
  "state": "string",
  "target": "string",
  "updated_at": "2026-01-01T00:00:00Z",
  "workspace_id": "string"
}
```
