> ## Documentation Index
> Fetch the complete documentation index at: https://ekacare-quickstart-cleanup.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Step 1: Upload Record

> Generate a presigned URL that allows you to securely upload a document to the server. This URL can be used to upload the document directly without needing additional authentication or authorization steps.

<Note>
  Constraints for File Upload:

  1. A client can create a maximum of 5 batches at a time.
  2. Each batch can include up to  10 files.
  3. All files in a batch must have the same content type.

  Valid Content Types:

  * Images:
  * `contentTypeJpg`  = "image/jpg"
  * `contentTypePng`  = "image/png"
  * Documents:
  * `contentTypePdf`  = "application/pdf"

  Valid File Sizes:

  * Maximum size for PDF files: `pdfMaxSizeMb` = 25 MB
  * Maximum size for image files: `imageMaxSizeMb` = 10 MB
</Note>


## OpenAPI

````yaml post /mr/api/v1/docs
openapi: 3.0.0
info:
  title: Document Upload API
  description: API to pre-sign the URL for uploading documents.
  version: 1.0.0
  license:
    name: Proprietary License
    url: https://developer.eka.care/license
servers:
  - url: https://api.eka.care
    description: Production server
  - url: https://api.dev.eka.care
    description: Development server
security: []
tags:
  - name: Records
    description: API related to records document management.
paths:
  /mr/api/v1/docs:
    post:
      tags:
        - Records
      summary: 'Step 1: Upload Record'
      description: >-
        Generate a presigned URL that allows you to securely upload a document
        to the server. This URL can be used to upload the document directly
        without needing additional authentication or authorization steps.
      operationId: getAuthorization
      parameters:
        - name: X-Pt-Id
          in: header
          required: true
          schema:
            type: string
          description: eka user id (OID)
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                batch_request:
                  type: array
                  items:
                    $ref: '#/components/schemas/UpdateDocumentV3Request'
            example:
              batch_request:
                - dt: ps
                  dd_e: 1614556800
                  tg:
                    - tag1
                    - tag2
                  files:
                    - contentType: image/jpeg
                      file_size: 110000
                  document_id: d1ed9519-d2aa-400b-a572-6e00701b9fb3
      responses:
        '200':
          description: Presigned URL successfully retrieved
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UploadResponse'
          links:
            GetDocumentByDocumentID:
              operationId: getDocument
              parameters:
                document_id: ‘$response.body#/batch_response/0/document_id’
              description: >
                The `document_id` value returned in the response can be used as
                the `document_id` parameter in `GET /mr/api/v1/docs/{id}`.
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorUploadResponse'
              examples:
                ErrorUploadResponse:
                  summary: Example of an error response with an empty batch_request
                  value:
                    error: true
                    message: Invalid document type.
                    batch_response: []
                    upload_time: null
        '500':
          description: Internal Server Error. No response body is expected.
        '502':
          description: Bad Gateway. No response body is expected.
        '503':
          description: Service Unavailable. No response body is expected.
        '504':
          description: Gateway Timeout. No response body is expected.
      security:
        - auth: []
components:
  schemas:
    UpdateDocumentV3Request:
      type: object
      properties:
        dt:
          $ref: '#/components/schemas/DocumentTypeQueryParam'
        document_id:
          type: string
          description: Unique identifier for the document.
        dd_e:
          type: integer
          format: int64
          description: Format should be in epoch seconds.
        tg:
          type: array
          uniqueItems: true
          description: >-
            Tags are treated as SET, and therefore their order is not preserved.
            The tag array can contain a maximum of **10 tags**. If more than 10
            tags are provided in the request, only the **first 10 tags** will be
            considered.
          items:
            type: string
            description: Each tag must be between **2 to 20 characters** in length.
        files:
          type: array
          description: >-
            A list of files to be uploaded, each with a specified content type
            and size.
          items:
            $ref: '#/components/schemas/FileUploadRequest'
        title:
          type: string
          nullable: true
          description: Title of the document. Max length of 256 characters.
        cases:
          type: array
          uniqueItems: true
          nullable: true
          items:
            type: string
          description: List of cases linked to a Medical Record.
        metadata:
          type: string
          description: Metadata associated with document (FHIR Bundle Format).
      required:
        - files
    UploadResponse:
      type: object
      properties:
        error:
          type: boolean
          example: false
        message:
          type: string
          example: ''
        batch_response:
          type: array
          items:
            $ref: '#/components/schemas/UploadResponseBody'
    ErrorUploadResponse:
      type: object
      properties:
        error:
          type: boolean
          example: true
        message:
          type: string
          description: Description of the error encountered
        batch_response:
          type: array
          items:
            $ref: '#/components/schemas/UploadResponseBody'
        token:
          type: string
          format: date-time
    DocumentTypeQueryParam:
      type: string
    FileUploadRequest:
      type: object
      properties:
        contentType:
          type: string
          description: The MIME type of the file (e.g., image/jpeg, application/pdf).
        file_size:
          type: integer
          format: int64
          description: Unit of file size should be bytes
      required:
        - contentType
        - file_size
    UploadResponseBody:
      type: object
      properties:
        document_id:
          type: string
        forms:
          type: array
          items:
            $ref: '#/components/schemas/UploadResponseBodyForms'
        error_details:
          type: object
          properties:
            message:
              type: string
            code:
              type: string
    UploadResponseBodyForms:
      type: object
      properties:
        url:
          type: string
        fields:
          type: object
          additionalProperties:
            type: string
  securitySchemes:
    auth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````