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

# Create or replace activities

> Creates or replaces 1 to 1,000 activities: events from your systems, such as a scored sales call, each about zero or more employees. An activity is identified by its type and externalId. Sending the same pair again replaces the whole activity, and an omitted field takes its default. Sending an archived activity again restores it. List activity types in activityTypes to create or update them first, so one request can define a type and send its activities. Sending an activity of an archived type restores the type, but not the type's other activities.

Each activity's access sets who can read and edit it: a preset, or an access object. Unless shareWithEmployees is false, the employees on the activity can read it too. Members with permission to manage activities (`activities.manage`) and the employee who created the activity can always read and edit it.

Creating an activity requires permission to manage activities (`activities.manage`). Replacing an existing activity requires that permission or write access to the activity. Every activity type write also requires that permission: an activityTypes entry, or an activity of an archived type, which restores the type. Without the permission, an activity you cannot write fails with 403 whether or not it exists.

An externalId, a type, and a tag are each limited to 512 characters. A field the request does not define fails validation, except the keys of properties, which you name. No text can contain the NUL character (U+0000) or a lone UTF-16 surrogate (U+D800 to U+DFFF).

The request succeeds or fails as a whole: when any item fails, nothing is written. error.details lists every failing item, each with its path in the request and a message. For example, when the second activity names an email that no employee has, the request fails with 400 and error.details is [{ "path": ["activities", 1, "employees", 0], "message": "No employee has the email omar@acme.example." }]. Validation errors, unknown types, employees, groups, or integrations, and ambiguous emails fail with 400. A write you may not make fails with 403, and its detail carries resourceId, the activity's id, only when you can read the activity. When both kinds occur, the status is 400 and details lists both. If your own employee record changes while the request is written, for example in an employee merge, the request fails with 409 and nothing is written; send it again. Repeating a request is safe: it replaces the same activities.



## OpenAPI

````yaml https://api.gowindmill.com/api/v2/openapi.json put /c/{companyId}/activities
openapi: 3.1.0
info:
  title: Windmill API
  version: 2.0.0
  description: >-
    Use the Windmill API to integrate your systems, automate workflows, and
    build applications on your organization's data. Authenticate with an API key
    or OAuth access token. Each request uses the authenticated user's
    permissions within the selected workspace.
servers:
  - url: https://api.gowindmill.com/api/v2
security:
  - bearerAuth: []
paths:
  /c/{companyId}/activities:
    put:
      tags:
        - Activities
      summary: Create or replace activities
      description: >-
        Creates or replaces 1 to 1,000 activities: events from your systems,
        such as a scored sales call, each about zero or more employees. An
        activity is identified by its type and externalId. Sending the same pair
        again replaces the whole activity, and an omitted field takes its
        default. Sending an archived activity again restores it. List activity
        types in activityTypes to create or update them first, so one request
        can define a type and send its activities. Sending an activity of an
        archived type restores the type, but not the type's other activities.


        Each activity's access sets who can read and edit it: a preset, or an
        access object. Unless shareWithEmployees is false, the employees on the
        activity can read it too. Members with permission to manage activities
        (`activities.manage`) and the employee who created the activity can
        always read and edit it.


        Creating an activity requires permission to manage activities
        (`activities.manage`). Replacing an existing activity requires that
        permission or write access to the activity. Every activity type write
        also requires that permission: an activityTypes entry, or an activity of
        an archived type, which restores the type. Without the permission, an
        activity you cannot write fails with 403 whether or not it exists.


        An externalId, a type, and a tag are each limited to 512 characters. A
        field the request does not define fails validation, except the keys of
        properties, which you name. No text can contain the NUL character
        (U+0000) or a lone UTF-16 surrogate (U+D800 to U+DFFF).


        The request succeeds or fails as a whole: when any item fails, nothing
        is written. error.details lists every failing item, each with its path
        in the request and a message. For example, when the second activity
        names an email that no employee has, the request fails with 400 and
        error.details is [{ "path": ["activities", 1, "employees", 0],
        "message": "No employee has the email omar@acme.example." }]. Validation
        errors, unknown types, employees, groups, or integrations, and ambiguous
        emails fail with 400. A write you may not make fails with 403, and its
        detail carries resourceId, the activity's id, only when you can read the
        activity. When both kinds occur, the status is 400 and details lists
        both. If your own employee record changes while the request is written,
        for example in an employee merge, the request fails with 409 and nothing
        is written; send it again. Repeating a request is safe: it replaces the
        same activities.
      operationId: activities.upsert
      parameters:
        - schema:
            type: string
            minLength: 1
            maxLength: 128
            description: >-
              Company ID. A URL slug is also accepted. The caller must have
              access to this company.
            title: Company ID
            example: company-acme
          required: true
          description: >-
            Company ID. A URL slug is also accepted. The caller must have access
            to this company.
          name: companyId
          in: path
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpsertActivitiesRequest'
      responses:
        '200':
          description: >-
            The activities are written. Returns each activity's id, in request
            order.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UpsertActivitiesResponse'
        '400':
          description: Bad request or request validation failed
          content:
            application/json:
              schema:
                anyOf:
                  - type: object
                    properties:
                      error:
                        type: object
                        properties:
                          code:
                            type: string
                            enum:
                              - BAD_REQUEST
                          message:
                            type: string
                          requestId:
                            type: string
                          details:
                            type: array
                            items:
                              type: object
                              properties:
                                path:
                                  type: array
                                  items:
                                    anyOf:
                                      - type: string
                                      - type: number
                                message:
                                  type: string
                                resourceId:
                                  type: string
                              required:
                                - path
                                - message
                            description: >-
                              Each request item that failed, by its path in the
                              request, when the operation identifies them.
                              resourceId names an existing resource the failure
                              concerns.
                        required:
                          - code
                          - message
                          - requestId
                    required:
                      - error
                  - type: object
                    properties:
                      error:
                        type: object
                        properties:
                          code:
                            type: string
                            enum:
                              - VALIDATION_ERROR
                          message:
                            type: string
                          requestId:
                            type: string
                          details:
                            type: array
                            items:
                              type: object
                              properties:
                                path:
                                  type: array
                                  items:
                                    anyOf:
                                      - type: string
                                      - type: number
                                message:
                                  type: string
                              required:
                                - path
                                - message
                        required:
                          - code
                          - message
                          - requestId
                          - details
                    required:
                      - error
        '401':
          description: >-
            Authentication is missing or invalid. Send a valid API key or OAuth
            access token in the Authorization: Bearer <TOKEN> header before
            retrying.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - UNAUTHORIZED
                      message:
                        type: string
                      requestId:
                        type: string
                    required:
                      - code
                      - message
                      - requestId
                required:
                  - error
        '403':
          description: >-
            Read-only API keys cannot call this operation. Creating an activity
            or writing an activity type requires permission to manage activities
            (`activities.manage`). Replacing an activity requires that
            permission or write access to the activity. This status is also
            returned when the API key or OAuth access token cannot access the
            workspace in the URL. A token works only in the workspace it was
            issued for, and only while its user is a member of that workspace.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - FORBIDDEN
                      message:
                        type: string
                      requestId:
                        type: string
                      details:
                        type: array
                        items:
                          type: object
                          properties:
                            path:
                              type: array
                              items:
                                anyOf:
                                  - type: string
                                  - type: number
                            message:
                              type: string
                            resourceId:
                              type: string
                          required:
                            - path
                            - message
                        description: >-
                          Each request item you lack permission for, by its path
                          in the request, when the operation identifies them.
                          resourceId names an existing resource the failure
                          concerns.
                    required:
                      - code
                      - message
                      - requestId
                required:
                  - error
        '409':
          description: Conflict
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - CONFLICT
                      message:
                        type: string
                      requestId:
                        type: string
                      details:
                        type: array
                        items:
                          type: object
                          properties:
                            path:
                              type: array
                              items:
                                anyOf:
                                  - type: string
                                  - type: number
                            message:
                              type: string
                            resourceId:
                              type: string
                          required:
                            - path
                            - message
                        description: >-
                          Request fields that caused the conflict, when the
                          operation identifies them. resourceId names the
                          existing resource that conflicts.
                    required:
                      - code
                      - message
                      - requestId
                required:
                  - error
        '429':
          description: >-
            The API-client request budget is exhausted. API keys allow 500
            requests per minute per key; OAuth clients allow 500 per minute per
            client and workspace. Reads and writes share the budget. One HTTP
            request counts once, including bulk requests. Wait for the
            Retry-After delay before retrying.
          headers:
            Retry-After:
              description: Number of seconds to wait before retrying the request.
              required: true
              schema:
                type: integer
                minimum: 0
                example: 42
            RateLimit:
              description: >-
                Current request budget: limit is the maximum count, remaining is
                the unused count, and reset is seconds until the window resets,
                not a timestamp.
              required: true
              schema:
                type: string
                example: limit=500, remaining=0, reset=42
            RateLimit-Policy:
              description: >-
                Request limit and window length in seconds, formatted as
                <limit>;w=<seconds>.
              required: true
              schema:
                type: string
                example: 500;w=60
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - RATE_LIMITED
                      message:
                        type: string
                      requestId:
                        type: string
                    required:
                      - code
                      - message
                      - requestId
                required:
                  - error
      security:
        - bearerAuth: []
components:
  schemas:
    UpsertActivitiesRequest:
      type: object
      properties:
        activityTypes:
          type: array
          items:
            $ref: '#/components/schemas/ActivityTypeInput'
          description: >-
            Activity types to create or update before the activities are
            written, so one request can define a type and send its activities.
            Each externalId can appear once. Requires permission to manage
            activities (`activities.manage`); without it, each entry fails and
            nothing is written.
        activities:
          type: array
          items:
            $ref: '#/components/schemas/ActivityInput'
          minItems: 1
          maxItems: 1000
          description: >-
            The activities to create or replace, from 1 to 1,000. Each type and
            externalId pair can appear once.
      required:
        - activities
      additionalProperties: false
      example:
        activityTypes:
          - externalId: call-score
            name: Call score
            description: A scored sales call. properties.score is 0 to 100.
        activities:
          - type: call-score
            externalId: call-8842
            employees:
              - email: jane@acme.example
            title: Discovery call with Northwind scored 82/100
            occurredAt: '2026-10-20T15:30:00Z'
            url: https://calls.example/call?id=8842
            properties:
              score: 82
              callType: Discovery
              account.name: Northwind
            tags:
              - q4-push
    UpsertActivitiesResponse:
      type: object
      properties:
        results:
          type: array
          items:
            type: object
            properties:
              type:
                type: string
                description: The externalId of the activity's type.
              externalId:
                type: string
                description: Your identifier for the event.
              id:
                type: string
                description: Windmill's identifier for the activity.
            required:
              - type
              - externalId
              - id
          description: One entry per written activity, in request order.
      required:
        - results
    ActivityTypeInput:
      type: object
      properties:
        externalId:
          type: string
          maxLength: 512
          pattern: \S
        name:
          type: string
          pattern: \S
        description:
          type: string
          pattern: \S
      required:
        - externalId
        - name
        - description
      additionalProperties: false
      description: An activity type to create, or to update by its externalId.
    ActivityInput:
      type: object
      properties:
        type:
          type: string
          maxLength: 512
          pattern: \S
        externalId:
          type: string
          maxLength: 512
          pattern: \S
        employees:
          type: array
          items:
            $ref: '#/components/schemas/ActivityEmployeeInput'
          default: []
          description: >-
            The employees the activity is about. Defaults to none. Archived
            employees can be named, and an employee named twice counts once. An
            email resolves to the one active employee who has it or, when no
            active employee has it, to the one archived employee who has it. An
            unknown employee or an ambiguous email fails the request.
        title:
          type: string
          pattern: \S
        occurredAt:
          type: string
          format: date-time
          description: >-
            When the event happened, as an RFC 3339 date-time with `Z` or a
            `±HH:MM` offset.
          example: '2026-10-20T15:30:00Z'
        url:
          type:
            - string
            - 'null'
          format: uri
          default: null
        body:
          type:
            - string
            - 'null'
          default: null
          description: Longer text about the event. Defaults to null.
        properties:
          $ref: '#/components/schemas/ActivityProperties'
        tags:
          type: array
          items:
            type: string
            maxLength: 512
            pattern: \S
          default: []
        integrationId:
          type:
            - string
            - 'null'
          default: null
        access:
          $ref: '#/components/schemas/ActivityAccessInput'
        shareWithEmployees:
          type: boolean
          default: true
          description: >-
            Defaults to true, with a preset or an access object alike: each
            employee on the activity can read it, whatever access allows. Set
            false to remove that grant, so the employees read the activity only
            when access includes them. For example, access MANAGERS with false
            shares an activity with an employee's managers but not with the
            employee.
      required:
        - type
        - externalId
        - title
        - occurredAt
      additionalProperties: false
      description: >-
        A complete activity, identified by type and externalId. Each write
        replaces the whole activity, and an omitted field takes its default: a
        resend without tags clears the tags, and one without access resets
        access to EMPLOYEE_AND_MANAGERS.
    ActivityEmployeeInput:
      anyOf:
        - type: object
          properties:
            employeeId:
              type: string
              minLength: 1
          required:
            - employeeId
          additionalProperties: false
        - type: object
          properties:
            email:
              type: string
              minLength: 1
          required:
            - email
          additionalProperties: false
      description: An employee, named by employeeId or by email.
    ActivityProperties:
      type: object
      additionalProperties:
        anyOf:
          - type: string
          - type: number
          - type: boolean
          - type: 'null'
          - type: array
            items:
              anyOf:
                - type: string
                - type: number
                - type: boolean
                - type: 'null'
      description: >-
        Structured details of the event as a flat object. Each value is a
        string, number, boolean, or null, or an array of those. An object value,
        or an array that holds an object or an array, fails validation. To group
        related details, put a `.` in the key, for example `account.name`; the
        whole key is one name.
      example:
        score: 82
        callType: Discovery
        account.name: Northwind
    ActivityAccessInput:
      anyOf:
        - $ref: '#/components/schemas/ActivityAccessPreset'
        - $ref: '#/components/schemas/ActivitySharingAccess'
      default: EMPLOYEE_AND_MANAGERS
      description: >-
        Who can read and edit the activity: a preset name, or an access object
        that grants read or write access to employees, groups, member
        capabilities, and reporting relationships. Write access includes read
        access. Defaults to EMPLOYEE_AND_MANAGERS. Every employee and group you
        name must belong to the company, or the request fails. Unless
        shareWithEmployees is false, the employees on the activity can also read
        it, with a preset or an access object alike. Members with permission to
        manage activities (`activities.manage`) and the employee who created the
        activity can always read and edit it.
      example: EMPLOYEE_AND_MANAGERS
    ActivityAccessPreset:
      type: string
      enum:
        - EMPLOYEE_AND_MANAGERS
        - MANAGERS
        - EMPLOYEE
        - ADMINS
        - PUBLIC
      description: >-
        A named access setting. Each preset grants read access.
        EMPLOYEE_AND_MANAGERS (the default): each employee on the activity and
        everyone above them in the reporting line. MANAGERS: everyone above each
        employee on the activity in the reporting line. EMPLOYEE: each employee
        on the activity. ADMINS: members with permission to view admin
        activities (`activities.view_admin`). PUBLIC: everyone in the company.
        With every preset, the employees on the activity can also read it unless
        shareWithEmployees is false.
    ActivitySharingAccess:
      type: object
      properties:
        companyAccess:
          type: string
          enum:
            - none
            - read
            - write
          default: none
          description: '`write` can read and edit; `none` removes the grant.'
        allManagersAccess:
          type: string
          enum:
            - none
            - read
            - write
          default: none
          description: Every employee with at least one report.
        employeeAccess:
          type: array
          items:
            type: object
            properties:
              employeeId:
                type: string
                minLength: 1
              access:
                type: string
                enum:
                  - none
                  - read
                  - write
                description: '`write` can read and edit; `none` removes the grant.'
            required:
              - employeeId
              - access
            additionalProperties: false
          default: []
        groupAccess:
          type: array
          items:
            type: object
            properties:
              groupId:
                type: string
                minLength: 1
              access:
                type: string
                enum:
                  - none
                  - read
                  - write
                description: '`write` can read and edit; `none` removes the grant.'
            required:
              - groupId
              - access
            additionalProperties: false
          default: []
        subtreeAccess:
          type: array
          items:
            type: object
            properties:
              employeeId:
                type: string
                minLength: 1
              access:
                type: string
                enum:
                  - none
                  - read
                  - write
                description: '`write` can read and edit; `none` removes the grant.'
            required:
              - employeeId
              - access
            additionalProperties: false
          default: []
          description: Everyone who reports to the employee, directly or not.
        capabilitiesAccess:
          type: array
          items:
            type: object
            properties:
              capability:
                type: string
                minLength: 1
                description: A workspace member capability.
              access:
                type: string
                enum:
                  - none
                  - read
                  - write
                description: '`write` can read and edit; `none` removes the grant.'
            required:
              - capability
              - access
            additionalProperties: false
          default: []
        relationshipAccess:
          type: array
          items:
            type: object
            properties:
              relationship:
                type: string
                enum:
                  - DIRECT_MANAGER
                  - MANAGER_HIERARCHY
                  - EMPLOYEE_AND_MANAGER_HIERARCHY
              employeeId:
                type: string
                minLength: 1
              access:
                type: string
                enum:
                  - none
                  - read
                  - write
                description: '`write` can read and edit; `none` removes the grant.'
            required:
              - relationship
              - employeeId
              - access
            additionalProperties: false
          default: []
          description: A grant to whoever holds a reporting relationship to the employee.
      additionalProperties: false
      description: >-
        Grants of read or write access to employees, groups, member
        capabilities, and reporting relationships. Activities cannot be shared
        with automations: an object that includes automationAccess, or any other
        unknown field, fails validation.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Use an API key or OAuth access token. Enter only the token in the
        authorization dialog; requests send it as `Authorization: Bearer
        <TOKEN>`.


        Create an API key in your workspace's **Settings → API keys**. Keys
        start with `wm_api_` and only work in the workspace where they were
        created. Read-only keys can read data; creating, updating, or deleting
        data requires a read-write key.


        ```http

        Authorization: Bearer wm_api_example

        ```


        OAuth access tokens are issued for connected Windmill applications.


        ```http

        Authorization: Bearer <OAUTH_ACCESS_TOKEN>

        ```


        Both token types use the authenticated user's workspace permissions.
        Each endpoint's permission requirements and the sharing settings of the
        requested items still apply.

````

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