---
title: "Create automation"
method: POST
path: "/workspaces/{workspace_id}/projects/{project_id}/automations"
tags: ["Automations"]
---

# Create automation

`POST /workspaces/{workspace_id}/projects/{project_id}/automations`

## Request

- Base URL: `https://app.mammoth.io/api/v2`
- URL: `https://app.mammoth.io/api/v2/workspaces/{workspace_id}/projects/{project_id}/automations`
- Auth: one of:
  - HTTP bearer
  - API key in header `X-API-KEY` and API key in header `X-API-SECRET` and API key in header `X-WORKSPACE-ID`

Create automation

## Path parameters

- `workspace_id` integer, required: Workspace refers to a collection of projects. Workspace ID is unique identifier for workspace.
- `project_id` integer, required: Project ID of the workspace

## Request body

- AutomationCreationSchema: Create automation
  - `name` string, required: Name
  - `description` string, required: Description
  - `tasks` AutomationTaskSchema[], required: Tasks
    - `task_type` 'run_data_retrieval' | 'append_data' | 'send_an_alert' | 'pull_cloud_files' | 'apply_retention_policy' | 'null', nullable: Task type
    - `details` TaskDetailsSchema
      - `datasource_id` integer, nullable: Dataset the retention policy applies to
      - `rule_type` 'time_based' | 'count_based' | 'condition_based' | 'null', nullable: Retention rule type
      - `threshold_value` integer, nullable: Number of minutes/hours/days/weeks/months for time-based rule
      - `threshold_unit` 'minutely' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'null', nullable: Unit for threshold_value
      - `keep_count` integer, nullable: Number of most-recent batches to keep for count-based rule
      - `condition_sql` string, nullable: WHERE clause predicate for condition_based rule
      - `intent` string, nullable: Natural language description used to generate the condition_sql
      - `notify` boolean: Send notification when policy runs
      - `notify_recipients` string[]: Email addresses to notify when policy runs or approval is requested
      - `notify_trigger` 'approval_and_policy_runs' | 'approval_only' | 'runs_only': When to send notifications: 'approval_and_policy_runs' sends on approval requests and policy runs, 'approval_only' sends only when approval is requested, 'runs_only' sends only when the policy runs (autonomous mode)
      - `require_approval` boolean: Whether to require manual approval before deletion
      - `action` 'delete' | 'suspend': Action to apply to matched batches: delete removes them, suspend hides them from views
      - `timezone` string, nullable: IANA timezone name for email notification timestamps (e.g. 'America/New_York')
      - `connector_key` string, nullable: Cloud connector identifier (e.g. 'google_drive', 'sftp', 'dropbox')
      - `connection_key` string, nullable: Identity key for the stored cloud connection credentials
      - `connection_profile` union: Connection Profile
        - string
        - string[]
      - `cloud_source_folder_path` union: Connector-specific folder identifier (Drive folder ID, SFTP path, GCS bucket/prefix, etc.)
        - CloudSourceFolderPath
          - `id` string, required
          - `path` string, required
        - string
      - `destination_folder_resource_id` integer, nullable: Resource ID of the Mammoth folder where datasets will be created
      - `ds_details` DataRefreshConfigSchema[], nullable: Dataset Details for automation task
        - `ds_id` integer, nullable: Dataset ID
      - `id` integer, nullable: Destination Dataset ID
      - `destination_dataset_ids` integer[], nullable: Destination dataset ids
      - `destination_dataset_id` integer, nullable: Single destination dataset id (pdf_orchestration only — one destination has exactly one watched folder, never a list; see destination_dataset_ids for append_data's many-sources shape)
      - `source_folder_resource_id` integer, nullable: Source Folder Resource ID
      - `source_dataset_id` integer, nullable: Source Dataset ID
      - `include_nested_folders` boolean, nullable: Include datasets from nested subfolders in source folder
      - `alert_type` 'email' | 'null', nullable: Alert type
      - `message` string, nullable: Message
      - `subject` string, nullable: Subject
      - `recipients` string[], nullable: Recipients
      - `attachments` object, nullable: Attachments
      - `test_email` boolean: Test Email
    - `conditions` object[]: Conditions
  - `conditions` AutomationConditionSchema[]: Conditions
    - `condition_type` 'at_specific_time' | 'new_data_addition_in_folder' | 'run_config' | 'cloud_source_name_pattern', required: Condition Type
    - `details` AutomationsSchemaConditionSchema, required
      - `contains` string, nullable: File name contains
      - `starts_with` string, nullable: File name prefix to match (case-insensitive)
      - `ends_with` string, nullable: File name suffix to match (case-insensitive)
      - `exact_match_with` string, nullable: Match exactly as given string
      - `include_subfolders` boolean, nullable: Include subfolders
      - `all_files` boolean, nullable: All files
      - `case_sensitive` boolean, nullable: Case Sensitive
      - `interval` integer, nullable: Interval
      - `frequency` 'minutely' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'null', nullable: Frequency
      - `start_at` string, date-time, nullable: Start At
      - `until` string, date-time, nullable: Until
      - `by_month_day` integer[], nullable: By Month Day
      - `by_week_day` string[], nullable: By Week Day
      - `start_now` boolean: start now/later
      - `file_contains` string, nullable: Name Contains
      - `execution_mode` 'parallel' | 'sequential': Execution Mode for task
      - `trigger_type` 'manual' | 'schedule': Execution trigger Type for automation
      - `on_refresh_action` 'replace' | 'combine' | 'append': On Refresh Action
      - `unique_sequence_column` UniqueSequenceCol
        - `c_name` string, required: Unique Sequence Column Name
        - `c_type` 'numeric' | 'date', required: Data Type of the Unique Sequence Column
  - `condition_mode` 'and' | 'or': Condition Mode

## Response `201`

Document created, URL follows

- object

## Other responses

- `202`: Create an automation
- `400`: Bad Request
- `401`: Authorization error
- `403`: Request forbidden -- authorization will not help

---

[API](https://skmtc.dev/mammoth/apis/mammoth-analytics.md) · [All operations](https://skmtc.dev/mammoth/apis/mammoth-analytics/llms.txt) · [OpenAPI document](https://skmtc.dev/mammoth/apis/mammoth-analytics/revisions/5dfd1c296ded?raw)
