---
title: "Creates a new attachment"
url: "https://developers.vzconnect.com/apis/fleet-inspections-api/versions/e4689b0c-c26d-40d6-b023-5303083c4a3f/operations/attachments-post"
---

> Full API specification: https://developers.vzconnect.com/apis/fleet-inspections-api/versions/e4689b0c-c26d-40d6-b023-5303083c4a3f.md

# Creates a new attachment

`POST` `/inspections/attachments`

Operation ID: `attachments-post`

Creates a new attachment of allowed types. Field *authorType* is provided by client and designates a role of author created an attachment. *authorId* and *authorName* are taken from profile of an authenticated user at the moment when attachment is created. When uploading an enclosure, the following headers should match POSTed data: - Content-Disposition: attachment: filename="__attachment.name__" - Content-Type: __attachment.enclosure.contentType__ - Content-Length: __attachment.enclosure.contentLength__ - otherwise 403 Forbidden is returned.

## Header parameters

- `Idempotency-Key` (string, required) - Carries an idempotency key in order to make non-idempotent HTTP methods such as POST or PATCH fault-tolerant. Must include quotes.

## Request body

Content types: `application/json`

## Responses

- `201` - Created
- `400` - Bad Request
- `401` - Unauthorized
- `403` - Forbidden
- `415` - Unsupported Media Type
- `429` - Too Many Requests
- `default` - Internal Server Error

## OpenAPI definition

```yaml
openapi: 3.0.0
info:
  title: Fleet Inspections API
  version: "1.0"
servers:
  - url: https://api.us.vzconnect.com
paths:
  /inspections/attachments:
    post:
      tags:
        - Fleet Inspections API
      summary: Creates a new attachment
      description: >-
        Creates a new attachment of allowed types.


        Field *authorType* is provided by client and designates a role of author
        created an attachment.


        *authorId* and *authorName* are taken from profile of an authenticated
        user at the moment when attachment is created.


        When uploading an enclosure, the following headers should match POSTed
        data:
          - Content-Disposition: attachment: filename="__attachment.name__"
          - Content-Type: __attachment.enclosure.contentType__
          - Content-Length: __attachment.enclosure.contentLength__
          - otherwise 403 Forbidden is returned.
      operationId: attachments-post
      parameters:
        - $ref: "#/components/parameters/IdempotencyKey"
      requestBody:
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Attachment"
            examples:
              Create a photo:
                value:
                  author:
                    authorType: OPERATOR
                  name: IMG_0096.JPG
                  enclosure:
                    contentLength: 954354
                    contentType: image/jpeg
                  attachmentType: PHOTO
              Create a signature:
                value:
                  author:
                    authorType: OPERATOR
                  name: Signing report
                  attachmentType: SIGNATURE
              Create a comment:
                value:
                  comment: Right side of the cabin is dirty, half of the door is covered in mud
                  attachmentType: COMMENT
                  author:
                    authorType: OPERATOR
      responses:
        "201":
          description: Created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Attachment"
              examples:
                Created signature:
                  value:
                    data:
                      - method: PUT
                        rel: enclosure
                        href: https://vzc.local/1uE2bfkwFgE5NHE7
                    name: Signing report
                    links:
                      - method: GET
                        rel: self
                        href: /attachments/yZkx8m1h1V5KAFNH
                    author:
                      name: John Doe
                      authorId: ke4Hdc5ua8dJYSLA
                      authorType: OPERATOR
                    attachmentType: SIGNATURE
                    attachmentId: yZkx8m1h1V5KAFNH
                Created comment:
                  value:
                    comment: Right side of the cabin is dirty, half of the door is covered in mud
                    attachmentId: htFdu2NWBFahb6Vb
                    author:
                      name: John Doe
                      authorId: 6DfLaFAeEJ4cKd5u
                      authorType: OPERATOR
                    attachmentType: COMMENT
                    links:
                      - method: GET
                        rel: self
                        href: /attachments/htFdu2NWBFahb6Vb
                Created photo:
                  value:
                    data:
                      - length: 954354
                        method: PUT
                        rel: enclosure
                        href: https://vzc.local/1uE2bfkwFgE5NHE7
                    name: IMG_0096.JPG
                    links:
                      - method: GET
                        rel: self
                        href: /attachments/yZkx8m1h1V5KAFNH
                    author:
                      name: John Doe
                      authorId: ke4Hdc5ua8dJYSLA
                      authorType: OPERATOR
                    attachmentType: PHOTO
                    attachmentId: yZkx8m1h1V5KAFNH
        "400":
          $ref: "#/components/responses/BadRequest"
          description: Bad request. The request is not valid.
        "401":
          $ref: "#/components/responses/Unauthorized"
          description: Unauthorized. The authorization token is missing or not valid.
        "403":
          $ref: "#/components/responses/Forbidden"
          description: Forbidden. The caller is not allowed to access this resource.
        "415":
          $ref: "#/components/responses/UnsupportedMediaType"
          description: Unsupported media type. The content type of the request is not
            supported.
        "429":
          $ref: "#/components/responses/TooManyRequests"
          description: Too many requests. The rate limit has been exceeded.
        default:
          $ref: "#/components/responses/InternalServerError"
          description: An unexpected error occurred.
      deprecated: false
      x-kong-route-defaults:
        strip_path: false
        paths:
          - ~/inspections/attachments/?$
components:
  parameters:
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      description: Carries an idempotency key in order to make non-idempotent HTTP
        methods such as POST or PATCH fault-tolerant. Must include quotes.
      required: true
      schema:
        maxLength: 120
        minLength: 1
        pattern: ^"[a-z0-9-]+"$
        type: string
  schemas:
    Attachment:
      title: Attachment
      required:
        - attachmentType
        - author
      type: object
      properties:
        data:
          maxItems: 100
          minItems: 0
          uniqueItems: true
          type: array
          description: Various media for an attachment
          readOnly: true
          items:
            type: object
            properties:
              rel:
                maxLength: 120
                minLength: 1
                pattern: ^(enclosure)$
                type: string
                description: |
                  Meaning of the values [described at IANA](https://www.iana.org/assignments/link-relations/link-relations.xhtml)
                    - *enclosure* - media, typically photo or document related to the resource, potentially large and might require special handling
              href:
                maxLength: 2000
                minLength: 1
                pattern: ^[^\n]+$
                type: string
                description: URL of relevant data
                format: uri
              method:
                type: string
                description: HTTP method to interact with data
                enum:
                  - GET
                  - PUT
              length:
                maximum: 6291456
                minimum: 1
                type: integer
                description: Size of a data referenced in *href* in bytes
                format: int32
              tags:
                maxItems: 100
                minItems: 0
                uniqueItems: true
                type: array
                description: Labels and attributes of a data enclosure
                readOnly: true
                items:
                  maxLength: 120
                  minLength: 1
                  pattern: ^[a-z0-9]+$
                  type: string
                  description: Individual label or attribute of a data enclosure
                  readOnly: true
            additionalProperties: false
        name:
          maxLength: 120
          minLength: 1
          pattern: ^[^\n]+$
          type: string
          description: Name of an attachment.
          nullable: true
        comment:
          maxLength: 2000
          minLength: 0
          pattern: ^[^\n]*$
          type: string
          description: Attachment details
          nullable: true
        enclosure:
          required:
            - contentLength
            - contentType
          type: object
          properties:
            contentLength:
              maximum: 6291456
              minimum: 1
              type: integer
              description: Size of media in bytes
              format: int32
            contentType:
              maxLength: 120
              minLength: 3
              pattern: ^(image\/jpeg|image\/png)$
              type: string
              description: Media type specifying format of the contents. See [RFC
                9110](https://www.rfc-editor.org/rfc/rfc9110.html#name-content-type)
                for details
          additionalProperties: false
          description: Related media, typically photo or document, potentially large and
            thus requiring separate upload facility
          writeOnly: true
        attachmentId:
          maxLength: 120
          minLength: 1
          pattern: ^[A-Za-z0-9-]{1,120}$
          type: string
          description: Unique identifier of an attachment.
          readOnly: true
        author:
          required:
            - authorType
          type: object
          properties:
            name:
              maxLength: 120
              minLength: 1
              pattern: ^[^\n]+$
              type: string
              description: Name of the author created an attachment.
              readOnly: true
            authorId:
              maxLength: 120
              minLength: 1
              pattern: ^[A-Za-z0-9-]{1,120}$
              type: string
              description: Unique identifier of the author created an attachment.
              readOnly: true
            authorType:
              type: string
              description: Person that created an attachment
              enum:
                - OPERATOR
                - COMPLIANCE_MANAGER
          additionalProperties: false
          description: Person that created an attachment
        attachmentType:
          $ref: "#/components/schemas/AttachmentType"
        links:
          maxItems: 100
          minItems: 0
          uniqueItems: true
          type: array
          description: Related resources
          readOnly: true
          items:
            $ref: "#/components/schemas/Link"
      additionalProperties: true
      description: |
        Inspection attachment: photo, signature, document, comment.

        *name* would be used as file name if enclosure is uploaded.
    AttachmentType:
      type: string
      description: Type of attachment, example Signature, Comment, Photo
      enum:
        - SIGNATURE
        - COMMENT
        - PHOTO
    Link:
      title: Link
      required:
        - href
        - rel
      type: object
      properties:
        rel:
          maxLength: 10
          minLength: 4
          pattern: ^(appendix|next|prev|self)$
          type: string
          description: |
            Meaning of the values [described at IANA](https://www.iana.org/assignments/link-relations/link-relations.xhtml)
              - *appendix* - refers to documents serving as an appendix to the current resource
              - *next* - context is a part of a series, and that the next in the series is the link target
              - *prev* - context is a part of a series, and that the previous in the series is the link target
              - *self* - URI of a resource or current page of the collection
        method:
          type: string
          description: HTTP method to interact with linked resource
          enum:
            - GET
            - PUT
        title:
          maxLength: 120
          minLength: 1
          pattern: ^[^\n]+$
          type: string
          description: Relation type with the target resource as human-readable text
        href:
          maxLength: 2000
          minLength: 1
          pattern: ^[^\n]+$
          type: string
          description: URL of linked resource
          format: uri-reference
      additionalProperties: false
      description: Reference to another resource
    ProblemJson:
      title: ProblemJson
      type: object
      properties:
        type:
          maxLength: 2000
          minLength: 0
          pattern: ^[^\n]*$
          type: string
          description: A URI reference that identifies the problem type.
          format: uri
        detail:
          maxLength: 2000
          minLength: 0
          pattern: ^[^\n]*$
          type: string
          description: A human-readable explanation specific to this occurrence of the
            problem.
        status:
          maximum: 599
          minimum: 300
          type: integer
          description: The HTTP status code generated by the origin server for this
            occurrence of the problem.
          format: int32
        errors:
          maxItems: 120
          minItems: 1
          uniqueItems: true
          type: array
          description: An extension that contains a list of individual error occurrences
            found, with details and a pointer to the location of each. Use this
            extension to convey more than one errors of the same type.
          items:
            type: object
            properties:
              debugId:
                maxLength: 120
                minLength: 0
                pattern: ^[^\n]*$
                type: string
                description: A unique error identifier string generated on the service-side and
                  logged for correlation purposes.
              pointer:
                maxLength: 120
                minLength: 0
                pattern: ^(\/[^\n]+)*$
                type: string
                description: A pointer to locate the problem within the request's content using
                  a [JSON Pointer](https://www.rfc-editor.org/info/rfc6901).
                  This extension is only applicable in case of 4xx range of
                  errors.
              detail:
                maxLength: 2000
                minLength: 0
                pattern: ^[^\n]*$
                type: string
                description: A human-readable explanation specific to this occurrence of the
                  problem.
            additionalProperties: false
        instance:
          maxLength: 2000
          minLength: 0
          pattern: ^[^\n]*$
          type: string
          description: A URI reference that identifies the specific occurrence of the
            problem. It may or may not yield further information if
            dereferenced.
          format: uri
        debugId:
          maxLength: 120
          minLength: 0
          pattern: ^[^\n]*$
          type: string
          description: A unique error identifier string generated on the service-side and
            logged for correlation purposes.
        pointer:
          maxLength: 120
          minLength: 0
          pattern: ^(\/[^\n]+)*$
          type: string
          description: A pointer to locate the problem within the request's content using
            a [JSON Pointer](https://www.rfc-editor.org/info/rfc6901). This
            extension is only applicable in case of 4xx range of errors.
        title:
          maxLength: 2000
          minLength: 0
          pattern: ^[^\n]*$
          type: string
          description: A short, human-readable summary of the problem type.
      additionalProperties: false
      description: JSON Schema for HTTP Problems as defined by RFC 9457
  responses:
    BadRequest:
      description: Bad Request
      content:
        application/problem+json:
          schema:
            $ref: "#/components/schemas/ProblemJson"
    Unauthorized:
      description: Unauthorized
      content:
        application/problem+json:
          schema:
            $ref: "#/components/schemas/ProblemJson"
    Forbidden:
      description: Forbidden
      content:
        application/problem+json:
          schema:
            $ref: "#/components/schemas/ProblemJson"
    UnsupportedMediaType:
      description: Unsupported Media Type
      content:
        application/problem+json:
          schema:
            $ref: "#/components/schemas/ProblemJson"
    TooManyRequests:
      description: Too Many Requests
      content:
        application/problem+json:
          schema:
            $ref: "#/components/schemas/ProblemJson"
    InternalServerError:
      description: Internal Server Error
      content:
        application/problem+json:
          schema:
            $ref: "#/components/schemas/ProblemJson"
```
