> ## Documentation Index
> Fetch the complete documentation index at: https://staging.docs.flowsign.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Save a template document's fields

> Applies `ops` to the fields of one template document, in order and all or nothing. `add` and `update` write the field with the given `id`, creating it when it does not exist; `remove` deletes it. `roleId` assigns the field to one of the template's roles (from `GET /api/v1/templates/:templateId`); an unknown role is a 400, and an `id` that belongs to another document is a 404. `position` is the field's top left and `size` its extent, both as 0 to 1 fractions of the page's width and height. Requires CREATE template access.



## OpenAPI

````yaml /api-reference/openapi.json put /api/v1/templates/{templateId}/fields
openapi: 3.0.3
info:
  title: Flowsign API
  version: 1.0.0
  description: >-
    Public v1 API for Flowsign. Every endpoint is authenticated with a Bearer
    API key (prefix `fsk_`). Errors use `{ error, details? }`; success responses
    wrap payload data as `{ data }`.


    An organisation is divided into workspaces. A key belongs to the
    organisation and acts in one workspace per request: pass `X-Workspace-Id`
    (see `GET /api/v1/workspaces`) or omit it to act in the default workspace.
    Packages, templates, contacts and members are scoped to the workspace the
    call acts in.
servers:
  - url: https://my.flowsign.app
    description: Production
security:
  - ApiKey: []
paths:
  /api/v1/templates/{templateId}/fields:
    put:
      tags:
        - Templates
      summary: Save a template document's fields
      description: >-
        Applies `ops` to the fields of one template document, in order and all
        or nothing. `add` and `update` write the field with the given `id`,
        creating it when it does not exist; `remove` deletes it. `roleId`
        assigns the field to one of the template's roles (from `GET
        /api/v1/templates/:templateId`); an unknown role is a 400, and an `id`
        that belongs to another document is a 404. `position` is the field's top
        left and `size` its extent, both as 0 to 1 fractions of the page's width
        and height. Requires CREATE template access.
      operationId: putTemplatesByTemplateIdFields
      parameters:
        - schema:
            type: string
          required: true
          name: templateId
          in: path
        - schema:
            type: string
            description: >-
              The workspace to act in, from `GET /api/v1/workspaces`. Omit to
              act in the organisation's default workspace. A workspace the key's
              user cannot act in is treated as omitted.
          required: false
          name: x-workspace-id
          in: header
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                documentId:
                  type: string
                  minLength: 1
                ops:
                  type: array
                  items:
                    oneOf:
                      - type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - add
                          field:
                            type: object
                            properties:
                              id:
                                type: string
                                minLength: 1
                              pageNumber:
                                type: integer
                                minimum: 0
                                exclusiveMinimum: true
                              fieldType:
                                type: string
                                enum:
                                  - text
                                  - signature
                                  - date
                                  - initial
                                  - comment
                                  - name
                                  - email
                                  - company
                                  - title
                                  - number
                                  - checkbox
                                  - radio
                                  - dropdown
                                  - formula
                                  - payment
                                  - label
                                  - attachment
                              position:
                                type: object
                                properties:
                                  x:
                                    type: number
                                  'y':
                                    type: number
                                required:
                                  - x
                                  - 'y'
                              size:
                                type: object
                                properties:
                                  width:
                                    type: number
                                  height:
                                    type: number
                                required:
                                  - width
                                  - height
                              isRequired:
                                type: boolean
                              placeholder:
                                type: string
                                nullable: true
                              dropdownOptions:
                                type: array
                                items:
                                  type: string
                              radioGroup:
                                type: string
                                nullable: true
                              roleId:
                                type: string
                                nullable: true
                                minLength: 1
                            required:
                              - id
                              - pageNumber
                              - fieldType
                              - position
                              - size
                        required:
                          - type
                          - field
                      - type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - update
                          field:
                            type: object
                            properties:
                              id:
                                type: string
                                minLength: 1
                              pageNumber:
                                type: integer
                                minimum: 0
                                exclusiveMinimum: true
                              fieldType:
                                type: string
                                enum:
                                  - text
                                  - signature
                                  - date
                                  - initial
                                  - comment
                                  - name
                                  - email
                                  - company
                                  - title
                                  - number
                                  - checkbox
                                  - radio
                                  - dropdown
                                  - formula
                                  - payment
                                  - label
                                  - attachment
                              position:
                                type: object
                                properties:
                                  x:
                                    type: number
                                  'y':
                                    type: number
                                required:
                                  - x
                                  - 'y'
                              size:
                                type: object
                                properties:
                                  width:
                                    type: number
                                  height:
                                    type: number
                                required:
                                  - width
                                  - height
                              isRequired:
                                type: boolean
                              placeholder:
                                type: string
                                nullable: true
                              dropdownOptions:
                                type: array
                                items:
                                  type: string
                              radioGroup:
                                type: string
                                nullable: true
                              roleId:
                                type: string
                                nullable: true
                                minLength: 1
                            required:
                              - id
                              - pageNumber
                              - fieldType
                              - position
                              - size
                        required:
                          - type
                          - field
                      - type: object
                        properties:
                          type:
                            type: string
                            enum:
                              - remove
                          field:
                            type: object
                            properties:
                              id:
                                type: string
                                minLength: 1
                            required:
                              - id
                        required:
                          - type
                          - field
              required:
                - documentId
                - ops
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      templateId:
                        type: string
                    required:
                      - templateId
                required:
                  - data
        '401':
          description: Missing or invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '402':
          description: Caller's plan does not include this feature (publicApi / webhooks)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: API key present but caller lacks the required permission
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '422':
          description: Request failed schema validation; details keyed by field
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded; see `Retry-After`
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    Error:
      type: object
      properties:
        error:
          type: string
        details:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
      required:
        - error
  securitySchemes:
    ApiKey:
      type: http
      scheme: bearer
      bearerFormat: fsk_*

````