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

# Assign temporary attachments to records

> Step 2 of the two-step upload flow: assigns temporary attachments previously created via `POST /attachments/temporary` to one or more records (candidate, company, or vacancy), making them permanent. The attachment's type is intended to be set here — each attachment specifies a `type`, either a predefined type (`{ name }`) or a custom, tenant-defined type (`{ id }`), and can optionally be renamed. At least one of candidateId, companyId, or vacancyId must be provided. The type must be allowed for all records the attachment is linked to: the predefined `CV` type can only be assigned to attachments linked to a candidate, and custom types define which record types they support.



## OpenAPI

````yaml /api-reference/openapi.json post /attachments/temporary/assign
openapi: 3.1.0
info:
  title: Spott API Reference
  version: '0.1'
servers:
  - url: https://api.gospott.com
security: []
tags: []
paths:
  /attachments/temporary/assign:
    post:
      tags:
        - Attachments
      summary: Assign temporary attachments to records
      description: >-
        Step 2 of the two-step upload flow: assigns temporary attachments
        previously created via `POST /attachments/temporary` to one or more
        records (candidate, company, or vacancy), making them permanent. The
        attachment's type is intended to be set here — each attachment specifies
        a `type`, either a predefined type (`{ name }`) or a custom,
        tenant-defined type (`{ id }`), and can optionally be renamed. At least
        one of candidateId, companyId, or vacancyId must be provided. The type
        must be allowed for all records the attachment is linked to: the
        predefined `CV` type can only be assigned to attachments linked to a
        candidate, and custom types define which record types they support.
      operationId: assignTemporaryAttachments
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AssignAttachmentsDto'
      responses:
        '204':
          description: Attachments assigned successfully
        '400':
          description: >-
            Bad request - invalid attachment IDs, missing record link (at least
            one of candidateId, companyId, or vacancyId required), invalid
            attachment type, or attachment type not allowed for the linked
            record
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ExceptionBaseDto'
                  - type: object
                    properties:
                      statusCode:
                        type: number
                        example: 400
                      message:
                        type: string
                        example: ATTACHMENT_TYPE_NOT_ALLOWED_FOR_RECORD_TYPE
                      error:
                        type: string
                        example: Bad Request
        '401':
          description: Unauthorized - invalid or missing authentication
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExceptionBaseDto'
        '404':
          description: Attachment not found - one or more attachment IDs do not exist
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/ExceptionBaseDto'
                  - type: object
                    properties:
                      statusCode:
                        type: number
                        example: 404
                      message:
                        type: string
                        example: Attachment not found
                      error:
                        type: string
                        example: Not Found
        '500':
          description: Error response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ExceptionBaseDto'
      security:
        - x-api-key: []
components:
  schemas:
    AssignAttachmentsDto:
      type: object
      properties:
        attachments:
          type: array
          items:
            $ref: '#/components/schemas/AssignAttachmentDto'
          description: >-
            List of temporary attachments to assign. Each attachment must
            include the ID returned from the upload endpoint, the desired
            attachment type, and optionally a new name for the file.
        candidateIds:
          description: >-
            IDs of the candidates to link the attachments to. Fully replaces the
            existing candidate links. At least one of candidateIds, companyIds,
            or vacancyIds must be provided.
          maxItems: 100
          type: array
          items:
            type: string
            minLength: 1
        companyIds:
          description: >-
            IDs of the companies to link the attachments to. Fully replaces the
            existing company links. At least one of candidateIds, companyIds, or
            vacancyIds must be provided.
          maxItems: 100
          type: array
          items:
            type: string
            minLength: 1
        vacancyIds:
          description: >-
            IDs of the vacancies/jobs to link the attachments to. Fully replaces
            the existing vacancy links. At least one of candidateIds,
            companyIds, or vacancyIds must be provided.
          maxItems: 100
          type: array
          items:
            type: string
            minLength: 1
        candidateId:
          description: >-
            [DEPRECATED] Use candidateIds instead. ID of a single candidate to
            link the attachments to; merged into candidateIds.
          deprecated: true
          example: 550e8400-e29b-41d4-a716-446655440000
          type: string
          minLength: 1
        companyId:
          description: >-
            [DEPRECATED] Use companyIds instead. ID of a single company to link
            the attachments to; merged into companyIds.
          deprecated: true
          example: 550e8400-e29b-41d4-a716-446655440001
          type: string
          minLength: 1
        vacancyId:
          description: >-
            [DEPRECATED] Use vacancyIds instead. ID of a single vacancy/job to
            link the attachments to; merged into vacancyIds.
          deprecated: true
          example: 550e8400-e29b-41d4-a716-446655440002
          type: string
          minLength: 1
      required:
        - attachments
      id: PrivateAssignAttachmentsDto
    ExceptionBaseDto:
      type: object
      properties:
        status:
          type: integer
          minimum: -9007199254740991
          maximum: 9007199254740991
        message:
          type: string
        requestId:
          type: string
      required:
        - status
        - message
        - requestId
      id: ExceptionBaseDto
    AssignAttachmentDto:
      type: object
      properties:
        id:
          type: string
          minLength: 1
          description: >-
            ID of the temporary attachment to assign. This is the ID returned
            from the upload temporary attachment endpoint.
          example: 550e8400-e29b-41d4-a716-446655440003
        type:
          $ref: '#/components/schemas/AttachmentTypeInputDto'
          description: >-
            The attachment type to assign — a predefined type (`{ name }`) or a
            custom, tenant-defined type (`{ id }`).
        name:
          description: >-
            Optional new name for the attachment. If not provided, the original
            filename from upload is preserved.
          example: John_Doe_CV_2026.pdf
          type: string
          minLength: 1
      required:
        - id
        - type
      id: PrivateAssignAttachmentDto
    AttachmentTypeInputDto:
      anyOf:
        - $ref: '#/components/schemas/CustomAttachmentTypeInputDto'
        - $ref: '#/components/schemas/SystemAttachmentTypeInputDto'
        - $ref: '#/components/schemas/SystemAttachmentTypeNameDto'
      id: PrivateAttachmentTypeInputDto
    CustomAttachmentTypeInputDto:
      type: object
      properties:
        id:
          type: string
          minLength: 1
      required:
        - id
      id: PrivateCustomAttachmentTypeInputDto
    SystemAttachmentTypeInputDto:
      type: object
      properties:
        name:
          type: string
          enum:
            - UNASSIGNED
            - CV
      required:
        - name
      id: PrivateSystemAttachmentTypeInputDto
    SystemAttachmentTypeNameDto:
      type: string
      enum:
        - UNASSIGNED
        - CV
      id: PrivateSystemAttachmentTypeNameDto
  securitySchemes:
    x-api-key:
      type: apiKey
      name: x-api-key
      in: header
      description: >-
        API key for authentication. Get your API key from Settings → API Keys in
        your Spott dashboard.

````