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

# Upload an immutable Python function as the next version of its name



## OpenAPI

````yaml /api-reference/serverless-functions.yaml post /compute/functions
openapi: 3.1.0
info:
  title: Functions
  version: v1
servers:
  - description: Droidrun Cloud API
    url: https://api.mobilerun.ai/v1
security:
  - bearerAuth: []
paths:
  /compute/functions:
    post:
      tags:
        - Functions
      summary: Upload an immutable Python function as the next version of its name
      operationId: createFunction
      parameters:
        - schema:
            type: string
            minLength: 1
            maxLength: 255
            pattern: ^[\x21-\x7E]{1,255}$
            description: >-
              Idempotency-Key: 1-255 printable ASCII characters. Same key with a
              different request body is a 422 idempotency_key_reused. A
              retryable in-flight duplicate is a 409 with Retry-After and
              x-should-retry: true; a terminal duplicate is a 409 with
              x-should-retry: false. A replay returns the current resource state
              with Idempotent-Replayed: true. Required.
            example: b3f6a9f0-6f1a-4e9a-9e7a-9c9b6b6a5a3f
          required: true
          description: >-
            Idempotency-Key: 1-255 printable ASCII characters. Same key with a
            different request body is a 422 idempotency_key_reused. A retryable
            in-flight duplicate is a 409 with Retry-After and x-should-retry:
            true; a terminal duplicate is a 409 with x-should-retry: false. A
            replay returns the current resource state with Idempotent-Replayed:
            true. Required.
          name: idempotency-key
          in: header
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateFunctionRequest'
      responses:
        '201':
          description: Function uploaded
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/ServerlessFunction'
                required:
                  - data
        '400':
          description: Error 400
          content:
            application/json:
              schema:
                anyOf:
                  - type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - invalid_idempotency_key
                      message:
                        type: string
                      traceId:
                        type: string
                      retryAfterSeconds:
                        type: number
                    required:
                      - code
                      - message
                  - type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - idempotency_key_required
                      message:
                        type: string
                      traceId:
                        type: string
                      retryAfterSeconds:
                        type: number
                    required:
                      - code
                      - message
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorEnvelope'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiErrorEnvelope'
        '404':
          description: Error 404
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    enum:
                      - function_not_found
                  message:
                    type: string
                  traceId:
                    type: string
                  retryAfterSeconds:
                    type: number
                required:
                  - code
                  - message
        '409':
          description: Error 409
          headers:
            Retry-After:
              description: Seconds until the request may be retried
              schema:
                type: string
          content:
            application/json:
              schema:
                anyOf:
                  - type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - function_published
                      message:
                        type: string
                      traceId:
                        type: string
                      retryAfterSeconds:
                        type: number
                    required:
                      - code
                      - message
                  - type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - function_limit_reached
                      message:
                        type: string
                      traceId:
                        type: string
                      retryAfterSeconds:
                        type: number
                    required:
                      - code
                      - message
                  - type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - function_busy
                      message:
                        type: string
                      traceId:
                        type: string
                      retryAfterSeconds:
                        type: number
                    required:
                      - code
                      - message
                  - type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - function_row_limit_reached
                      message:
                        type: string
                      traceId:
                        type: string
                      retryAfterSeconds:
                        type: number
                    required:
                      - code
                      - message
                  - type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - idempotency_request_in_progress
                      message:
                        type: string
                      traceId:
                        type: string
                      retryAfterSeconds:
                        type: number
                    required:
                      - code
                      - message
                  - type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - idempotency_key_consumed
                      message:
                        type: string
                      traceId:
                        type: string
                      retryAfterSeconds:
                        type: number
                    required:
                      - code
                      - message
        '413':
          description: Error 413
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    enum:
                      - function_too_large
                  message:
                    type: string
                  traceId:
                    type: string
                  retryAfterSeconds:
                    type: number
                required:
                  - code
                  - message
        '422':
          description: Manifest or name invalid, or idempotency key reused
          content:
            application/json:
              schema:
                anyOf:
                  - allOf:
                      - $ref: '#/components/schemas/ApiErrorEnvelope'
                      - type: object
                        properties:
                          code:
                            type: string
                            enum:
                              - manifest_invalid
                          details:
                            type: array
                            items:
                              type: object
                              properties:
                                field:
                                  type: string
                                message:
                                  type: string
                              required:
                                - field
                                - message
                        required:
                          - details
                  - allOf:
                      - $ref: '#/components/schemas/ApiErrorEnvelope'
                      - type: object
                        properties:
                          code:
                            type: string
                            enum:
                              - function_name_invalid
                          details:
                            type: array
                            items:
                              type: object
                              properties:
                                field:
                                  type: string
                                message:
                                  type: string
                              required:
                                - field
                                - message
                        required:
                          - details
                  - type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - idempotency_key_reused
                      message:
                        type: string
                      traceId:
                        type: string
                      retryAfterSeconds:
                        type: number
                    required:
                      - code
                      - message
        '429':
          description: Error 429
          headers:
            Retry-After:
              description: Seconds until the request may be retried
              schema:
                type: string
          content:
            application/json:
              schema:
                anyOf:
                  - type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - function_rate_limited
                      message:
                        type: string
                      traceId:
                        type: string
                      retryAfterSeconds:
                        type: number
                    required:
                      - code
                      - message
                  - type: object
                    properties:
                      code:
                        type: string
                        enum:
                          - inspection_budget_exhausted
                      message:
                        type: string
                      traceId:
                        type: string
                      retryAfterSeconds:
                        type: number
                    required:
                      - code
                      - message
        '500':
          description: Error 500
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    enum:
                      - function_integrity_error
                  message:
                    type: string
                  traceId:
                    type: string
                  retryAfterSeconds:
                    type: number
                required:
                  - code
                  - message
        '503':
          description: Error 503
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    enum:
                      - storage_unavailable
                  message:
                    type: string
                  traceId:
                    type: string
                  retryAfterSeconds:
                    type: number
                required:
                  - code
                  - message
components:
  schemas:
    CreateFunctionRequest:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 120
        description:
          type: string
          maxLength: 2000
        source:
          type: string
          minLength: 1
        manifest:
          $ref: '#/components/schemas/FunctionManifest'
      required:
        - name
        - source
      additionalProperties: false
    ServerlessFunction:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        version:
          type: integer
          minimum: 1
          description: Per-name version number, starting at 1 and never reused.
        versionCount:
          type: integer
          minimum: 1
          description: >-
            Number of active versions of this name. Only set when listing with
            latest=true.
        description:
          type:
            - string
            - 'null'
        sha256:
          type: string
          pattern: ^[a-f0-9]{64}$
        sizeBytes:
          type: integer
        status:
          $ref: '#/components/schemas/FunctionStatus'
        manifest:
          $ref: '#/components/schemas/FunctionManifest'
        inputSchema:
          type:
            - object
            - 'null'
          additionalProperties: {}
        outputSchema:
          type:
            - object
            - 'null'
          additionalProperties: {}
        outputKind:
          type:
            - string
            - 'null'
        datasetKey:
          type:
            - string
            - 'null'
        inspectError:
          $ref: '#/components/schemas/InspectError'
        runtimeVersion:
          type:
            - string
            - 'null'
        createdBy:
          type: string
        createdAt:
          type: string
          format: date-time
      required:
        - id
        - name
        - version
        - description
        - sha256
        - sizeBytes
        - status
        - manifest
        - inputSchema
        - outputSchema
        - outputKind
        - datasetKey
        - inspectError
        - runtimeVersion
        - createdBy
        - createdAt
    ApiErrorEnvelope:
      properties:
        code:
          type: string
        details: {}
        message:
          type: string
        retryAfterSeconds:
          type: number
        traceId:
          type: string
      required:
        - code
        - message
      type: object
    FunctionManifest:
      type: object
      properties:
        hosts:
          type: array
          items:
            type: string
            maxLength: 253
          maxItems: 20
          default: []
        credentials:
          type: array
          items:
            type: object
            properties:
              packageName:
                type: string
                minLength: 1
                maxLength: 200
              name:
                type: string
                minLength: 1
                maxLength: 200
            required:
              - packageName
              - name
            additionalProperties: false
          maxItems: 20
          default: []
        scopes:
          type: array
          items:
            type: string
            minLength: 1
            maxLength: 100
            pattern: ^[a-z_]+\.[a-z_]+$
          maxItems: 30
          default: []
      default:
        hosts: []
        credentials: []
        scopes: []
      additionalProperties: false
    FunctionStatus:
      type: string
      enum:
        - pending_inspection
        - ready
        - rejected
    InspectError:
      type:
        - object
        - 'null'
      properties:
        code:
          type: string
        message:
          type: string
        errors:
          type: array
          items:
            $ref: '#/components/schemas/InspectionIssue'
          maxItems: 20
      required:
        - code
        - message
    InspectionIssue:
      type: object
      properties:
        code:
          type: string
          maxLength: 64
        message:
          type: string
        line:
          type: integer
          exclusiveMinimum: 0
        repair:
          type: object
          properties:
            action:
              type: string
              maxLength: 64
            hint:
              type: string
          required:
            - action
            - hint
          additionalProperties: false
      required:
        - code
        - message
      additionalProperties: false
  securitySchemes:
    bearerAuth:
      bearerFormat: Opaque
      description: Bearer token via Authorization header
      scheme: bearer
      type: http

````

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