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

# Replace a DRAFT campaign's custom extraction keys

**Required scope:** `campaigns.edit`


## OpenAPI

````yaml /api-reference/openapi.json put /campaigns/{id}/custom-keys
openapi: 3.0.3
info:
  title: Pineyard API
  version: 1.0.0
  description: >-
    Programmatic access to agents, campaigns, calls, phone numbers, WhatsApp and
    results in your Pineyard workspace.
servers:
  - url: https://api.pineyard.ai
    description: Production
security:
  - bearerAuth: []
paths:
  /campaigns/{id}/custom-keys:
    put:
      summary: Replace a DRAFT campaign's custom extraction keys
      parameters:
        - schema:
            type: string
          required: true
          name: id
          in: path
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                customExtractionKeys:
                  type: array
                  items:
                    type: object
                    properties:
                      name:
                        type: string
                        minLength: 1
                        maxLength: 64
                        pattern: ^[a-zA-Z_][a-zA-Z0-9_]*$
                      type:
                        type: string
                        enum:
                          - string
                          - number
                          - integer
                          - boolean
                          - array
                          - date
                          - datetime
                      description:
                        type: string
                        minLength: 1
                        maxLength: 500
                    required:
                      - name
                      - type
                      - description
                  maxItems: 40
              required:
                - customExtractionKeys
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                  name:
                    type: string
                  description:
                    type: string
                    nullable: true
                  agentId:
                    type: string
                    nullable: true
                  agentName:
                    type: string
                    nullable: true
                  channel:
                    type: string
                    enum:
                      - VOICE
                      - WHATSAPP
                      - VOICE_THEN_WHATSAPP
                      - WHATSAPP_THEN_VOICE
                      - CUSTOM
                      - EMAIL
                  whatsappOutreachTemplateId:
                    type: string
                    nullable: true
                  whatsappTemplateByMetric:
                    nullable: true
                  messageDeclinedLeads:
                    type: boolean
                  dailyMessageCap:
                    type: number
                    nullable: true
                  outreachRules:
                    type: array
                    nullable: true
                    items:
                      type: object
                      properties:
                        trigger:
                          type: string
                          enum:
                            - MESSAGE_REPLY
                            - NO_REPLY_AFTER
                            - CALL_ENDED
                        afterDays:
                          type: integer
                          minimum: 1
                          maximum: 90
                        condition:
                          oneOf:
                            - type: object
                              properties:
                                kind:
                                  type: string
                                  enum:
                                    - ai_interested
                                describe:
                                  type: string
                                  maxLength: 500
                              required:
                                - kind
                            - type: object
                              properties:
                                kind:
                                  type: string
                                  enum:
                                    - reply_contains
                                any:
                                  type: array
                                  items:
                                    type: string
                                    minLength: 1
                                    maxLength: 80
                                  minItems: 1
                                  maxItems: 20
                              required:
                                - kind
                                - any
                            - type: object
                              properties:
                                kind:
                                  type: string
                                  enum:
                                    - metric_is
                                key:
                                  type: string
                                  minLength: 1
                                  maxLength: 120
                                values:
                                  type: array
                                  items:
                                    type: string
                                    minLength: 1
                                    maxLength: 80
                                  minItems: 1
                                  maxItems: 20
                              required:
                                - kind
                                - key
                                - values
                            - type: object
                              properties:
                                kind:
                                  type: string
                                  enum:
                                    - call_outcome_in
                                values:
                                  type: array
                                  items:
                                    type: string
                                    minLength: 1
                                    maxLength: 40
                                  minItems: 1
                                  maxItems: 10
                              required:
                                - kind
                                - values
                        conditions:
                          type: array
                          items:
                            oneOf:
                              - type: object
                                properties:
                                  kind:
                                    type: string
                                    enum:
                                      - ai_interested
                                  describe:
                                    type: string
                                    maxLength: 500
                                required:
                                  - kind
                              - type: object
                                properties:
                                  kind:
                                    type: string
                                    enum:
                                      - reply_contains
                                  any:
                                    type: array
                                    items:
                                      type: string
                                      minLength: 1
                                      maxLength: 80
                                    minItems: 1
                                    maxItems: 20
                                required:
                                  - kind
                                  - any
                              - type: object
                                properties:
                                  kind:
                                    type: string
                                    enum:
                                      - metric_is
                                  key:
                                    type: string
                                    minLength: 1
                                    maxLength: 120
                                  values:
                                    type: array
                                    items:
                                      type: string
                                      minLength: 1
                                      maxLength: 80
                                    minItems: 1
                                    maxItems: 20
                                required:
                                  - kind
                                  - key
                                  - values
                              - type: object
                                properties:
                                  kind:
                                    type: string
                                    enum:
                                      - call_outcome_in
                                  values:
                                    type: array
                                    items:
                                      type: string
                                      minLength: 1
                                      maxLength: 40
                                    minItems: 1
                                    maxItems: 10
                                required:
                                  - kind
                                  - values
                          minItems: 1
                          maxItems: 5
                        match:
                          type: string
                          enum:
                            - ALL
                            - ANY
                          default: ALL
                        action:
                          type: string
                          enum:
                            - HAND_OFF
                            - STOP
                            - MARK_INTERESTED
                          default: HAND_OFF
                      required:
                        - trigger
                    maxItems: 20
                  whatsappEnabled:
                    type: boolean
                  whatsappAgentTemplateIds:
                    type: array
                    items:
                      type: string
                  whatsappPaymentLinkEnabled:
                    type: boolean
                  recoveryLinkEnabled:
                    type: boolean
                  whatsappAutomations:
                    type: array
                    items:
                      type: object
                      properties:
                        key:
                          type: string
                        label:
                          type: string
                        detail:
                          type: string
                      required:
                        - key
                        - label
                        - detail
                  workflowId:
                    type: string
                    nullable: true
                  status:
                    type: string
                  reservedConcurrency:
                    type: number
                  variableMap:
                    type: object
                    additionalProperties:
                      type: string
                  countryCode:
                    type: string
                    nullable: true
                  phoneColumn:
                    type: string
                    nullable: true
                  altPhoneColumns:
                    type: array
                    items:
                      type: string
                  removeInvalidRows:
                    type: boolean
                  transliterateCalleeNames:
                    type: boolean
                  uploadId:
                    type: string
                    nullable: true
                  timezone:
                    type: string
                    nullable: true
                  scheduledStartAt:
                    type: string
                    nullable: true
                  scheduledEndAt:
                    type: string
                    nullable: true
                  dailyWindowStart:
                    type: string
                    nullable: true
                  dailyWindowEnd:
                    type: string
                    nullable: true
                  retryCount:
                    type: number
                  cooldownMinutes:
                    type: number
                  retryDelaysMinutes:
                    type: array
                    items:
                      type: number
                  retryConcurrencyPercent:
                    type: number
                    nullable: true
                  startedAt:
                    type: string
                    nullable: true
                  endedAt:
                    type: string
                    nullable: true
                  createdAt:
                    type: string
                  updatedAt:
                    type: string
                  campaignTypeId:
                    type: string
                    nullable: true
                  campaignTypeName:
                    type: string
                    nullable: true
                  customExtractionKeys:
                    type: array
                    items:
                      type: object
                      properties:
                        name:
                          type: string
                          minLength: 1
                          maxLength: 64
                          pattern: ^[a-zA-Z_][a-zA-Z0-9_]*$
                        type:
                          type: string
                          enum:
                            - string
                            - number
                            - integer
                            - boolean
                            - array
                            - date
                            - datetime
                        description:
                          type: string
                          minLength: 1
                          maxLength: 500
                      required:
                        - name
                        - type
                        - description
                  effectiveExtractionKeys:
                    type: array
                    items:
                      type: object
                      properties:
                        name:
                          type: string
                          minLength: 1
                          maxLength: 64
                          pattern: ^[a-zA-Z_][a-zA-Z0-9_]*$
                        type:
                          type: string
                          enum:
                            - string
                            - number
                            - integer
                            - boolean
                            - array
                            - date
                            - datetime
                        description:
                          type: string
                          minLength: 1
                          maxLength: 500
                      required:
                        - name
                        - type
                        - description
                  notificationUserIds:
                    type: array
                    items:
                      type: string
                  source:
                    type: string
                    enum:
                      - CSV
                      - CRM_MANUAL
                      - CRM_WEBHOOK
                      - API
                      - INBOUND
                  defaultCrmConnectionId:
                    type: string
                    nullable: true
                  defaultCrmSegmentId:
                    type: string
                    nullable: true
                  followupEnabled:
                    type: boolean
                  followupMaxAttempts:
                    type: number
                  churnEnabled:
                    type: boolean
                  churnMaxAttempts:
                    type: number
                  churnIntervalHours:
                    type: number
                  churnDelaysHours:
                    type: array
                    items:
                      type: number
                  goal:
                    type: string
                    nullable: true
                  incompleteRetryEnabled:
                    type: boolean
                  incompleteRetryMaxAttempts:
                    type: number
                  incompleteRetryIntervalMinutes:
                    type: number
                  incompleteRetryDelaysMinutes:
                    type: array
                    items:
                      type: number
                  incompleteCallSeconds:
                    type: number
                  referralMaxDepth:
                    type: number
                  skipRetryOnFirstVoicemail:
                    type: boolean
                  messageRetryEnabled:
                    type: boolean
                  messageRetryMaxAttempts:
                    type: number
                  messageRetryIntervalSeconds:
                    type: number
                  messageRetryDelaysSeconds:
                    type: array
                    items:
                      type: number
                  messageRetryWindowSeconds:
                    type: number
                  messageRetryTieredEnabled:
                    type: boolean
                  messageRetryTransientMaxAttempts:
                    type: number
                  autoReseedEnabled:
                    type: boolean
                  briefFileName:
                    type: string
                    nullable: true
                  briefUploadedAt:
                    type: string
                    nullable: true
                  briefText:
                    type: string
                    nullable: true
                  dailyDialCap:
                    type: number
                    nullable: true
                  dialDays:
                    type: array
                    items:
                      type: number
                  evaluationMetrics:
                    type: array
                    items:
                      type: object
                      properties:
                        key:
                          type: string
                          minLength: 1
                          maxLength: 64
                          pattern: ^[a-z][a-z0-9_]*$
                        label:
                          type: string
                          minLength: 1
                          maxLength: 60
                        allowedValues:
                          type: array
                          items:
                            type: string
                            minLength: 1
                            maxLength: 40
                          minItems: 2
                          maxItems: 24
                        prompt:
                          type: string
                          minLength: 1
                          maxLength: 5000
                        builtin:
                          type: boolean
                      required:
                        - key
                        - label
                        - allowedValues
                        - prompt
                    maxItems: 12
                  contactCount:
                    type: number
                  receivedCalls:
                    type: number
                required:
                  - id
                  - name
                  - agentId
                  - agentName
                  - channel
                  - status
                  - reservedConcurrency
                  - variableMap
                  - startedAt
                  - endedAt
                  - createdAt
                  - updatedAt
                  - campaignTypeId
                  - campaignTypeName
                  - customExtractionKeys
                  - effectiveExtractionKeys
                  - notificationUserIds
                  - source
                  - defaultCrmConnectionId
                  - defaultCrmSegmentId
        '400':
          description: >-
            - `internal_error`: An unexpected error. A `400` with this code
            usually means the body is not valid JSON; a `413` means the body is
            larger than 1 MB.

            - `invalid_body`: The request body (or query) failed validation.
            Details are in `issues` (or `detail`). `422` on `POST
            /v1/campaigns/{campaignId}/leads`.
        '401':
          description: >-
            - `invalid_api_key`: The API key is unknown, revoked or expired, or
            its workspace was deleted.

            - `unauthorized`: No `Authorization: Bearer` header, or an empty
            token.
        '403':
          description: >-
            - `api_key_not_scoped`: A key issued without scopes was used outside
            `/v1`.

            - `api_key_owner_inactive`: The member the key acts for was removed
            or suspended.

            - `forbidden`: The key lacks the permission named in
            `requiredPermission`, or the resource belongs to another workspace.

            - `workspace_pending_approval`: The workspace has not been approved
            yet.

            - `workspace_suspended`: The workspace is suspended.
        '404':
          description: >-
            - `not_found`: The resource does not exist in your workspace, or the
            feature is not enabled for it.
        '409':
          description: >-
            - `campaign_not_draft`: Campaign can only be changed in DRAFT (or
            PAUSED/CREDIT_EXHAUSTED for edits; contacts only in DRAFT).
        '413':
          description: >-
            - `internal_error`: An unexpected error. A `400` with this code
            usually means the body is not valid JSON; a `413` means the body is
            larger than 1 MB.
        '429':
          description: '- `rate_limited`: Too many requests.'
        '500':
          description: >-
            - `internal_error`: An unexpected error. A `400` with this code
            usually means the body is not valid JSON; a `413` means the body is
            larger than 1 MB.
        '502':
          description: >-
            - `provider_error`: The calling service rejected the request
            (`upstreamStatus` 4xx) or was unavailable (5xx).
        '503':
          description: '- `database_unavailable`: The service is temporarily unavailable.'
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Your API key, e.g. `pk_live_xxxxxxxxxxxxxxxxxxxxxxxx`.

````

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