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

# Upload media files to CDN

> Uploads one or more media files to the GoStudio CDN. Accepts HTTPS URLs, data URIs (`data:image/png;base64,...`), raw base64 strings (requires `mime_type`), or binary multipart uploads.

Returns a result per item. The overall request returns `200` even if some items fail — check `summary.failed` and the per-item `error` field. Returns `422` only when **every** item in the batch is NSFW-flagged. Accepts up to 20 items per request.




## OpenAPI

````yaml /openapi.yaml post /api/v2/media/upload
openapi: 3.0.3
info:
  title: GoStudio API
  version: 2.0.0
  description: >
    The GoStudio v2 REST API. Every response uses a standard envelope: successes
    return `{ status, data }`; errors return `{ status, error: { type, code,
    message } }`.


    All endpoints require a **Bearer token** in the `Authorization` header. The
    one exception is the provider webhook callback, which is authenticated by
    signature.
servers:
  - url: https://www.gostudio.ai
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Watermark Remover
    description: AI watermark removal — orchestration, model metadata, and job polling.
  - name: Photo
    description: >-
      AI photo generation — generate, recreate, and manage trained profile
      photos.
  - name: Image
    description: Image utilities — group photo composition and image-to-prompt analysis.
  - name: Media
    description: Media upload and CDN management.
  - name: Apps
    description: GoStudio application tools — age modifier and other transformations.
  - name: Job Status
    description: Generic job polling — works across all GoStudio tools.
  - name: Webhooks
    description: Endpoints called by external services, not by your application.
paths:
  /api/v2/media/upload:
    post:
      tags:
        - Media
      summary: Upload media files to CDN
      description: >
        Uploads one or more media files to the GoStudio CDN. Accepts HTTPS URLs,
        data URIs (`data:image/png;base64,...`), raw base64 strings (requires
        `mime_type`), or binary multipart uploads.


        Returns a result per item. The overall request returns `200` even if
        some items fail — check `summary.failed` and the per-item `error` field.
        Returns `422` only when **every** item in the batch is NSFW-flagged.
        Accepts up to 20 items per request.
      operationId: uploadMedia
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UploadRequest'
            examples:
              url:
                summary: Upload by HTTPS URL
                value:
                  urls:
                    - https://example.com/photo.jpg
                  nsfw_check: true
                  purpose: group-photo-input
              data_uri:
                summary: Upload via data URI
                value:
                  urls:
                    - data:image/png;base64,iVBORw0KGgo...
                  mime_type: image/png
          multipart/form-data:
            schema:
              type: object
              properties:
                nsfw_check:
                  type: string
                  description: Run NSFW classifier. `"true"` (default) or `"false"`.
                  example: 'true'
                purpose:
                  type: string
                  description: Label for the upload batch.
      responses:
        '200':
          description: >
            Upload processed. Check `summary.failed` and per-item `error` fields
            for partial failures.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: integer
                    example: 200
                  results:
                    type: array
                    items:
                      $ref: '#/components/schemas/UploadResult'
                  summary:
                    type: object
                    properties:
                      total:
                        type: integer
                        description: Total items submitted.
                        example: 2
                      uploaded:
                        type: integer
                        description: Successfully uploaded items.
                        example: 2
                      failed:
                        type: integer
                        description: Failed items.
                        example: 0
                      nsfw_flagged:
                        type: integer
                        description: NSFW-flagged items.
                        example: 0
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '415':
          description: One or more files have an unsupported media type.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                status: 415
                error:
                  type: invalid_file_type
                  code: 41500
                  message: Unsupported file type.
        '422':
          description: Every item in the batch was flagged as NSFW.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                status: 422
                error:
                  type: nsfw_content
                  code: 42293
                  message: All uploaded images were flagged as NSFW.
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/ServerError'
components:
  schemas:
    UploadRequest:
      type: object
      required:
        - urls
      properties:
        urls:
          type: array
          description: >
            Items to upload. Each can be an HTTPS URL, a data URI
            (`data:mime;base64,...`), or a raw base64 string (requires
            `mime_type`). Maximum 20 items.
          items:
            type: string
          minItems: 1
          maxItems: 20
          example:
            - https://example.com/photo.jpg
        nsfw_check:
          type: boolean
          description: Run NSFW classifier on images.
          default: true
        purpose:
          type: string
          description: Label for the upload batch.
          example: group-photo-input
        tool:
          type: string
          description: Tool name that triggered this upload.
          example: group-photo
        mime_type:
          type: string
          description: MIME type hint, required when `urls` contains raw base64 strings.
          example: image/png
    UploadResult:
      type: object
      properties:
        source_url:
          type: string
          description: The original URL or identifier submitted.
        cdn_url:
          type: string
          format: uri
          nullable: true
          description: GoStudio CDN URL for the uploaded file.
        raw_url:
          type: string
          format: uri
          nullable: true
          description: Raw storage URL for the uploaded file.
        media_type:
          type: string
          enum:
            - image
            - video
            - audio
            - document
          nullable: true
          description: Detected media type.
        content_type:
          type: string
          nullable: true
          description: MIME type of the uploaded file.
        nsfw_checked:
          type: boolean
          description: Whether the NSFW classifier ran on this item.
        nsfw_flagged:
          type: boolean
          description: Whether this item was flagged as NSFW.
        error:
          type: string
          nullable: true
          description: Error code if this item failed. Present only on failure.
        message:
          type: string
          nullable: true
          description: Error detail. Present only on failure.
    ErrorResponse:
      type: object
      properties:
        status:
          type: integer
          example: 400
        error:
          type: object
          properties:
            type:
              type: string
              example: validation_error
            code:
              type: string
              example: invalid_input
            dev:
              type: integer
              example: 40001
            message:
              type: string
              example: Some information is invalid.
  responses:
    BadRequest:
      description: The request was malformed or failed validation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            status: 400
            error:
              type: validation_error
              code: invalid_input
              dev: 40001
              message: Some information is invalid.
    Unauthorized:
      description: Missing or invalid Authorization Bearer token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            status: 401
            error:
              type: authentication_error
              code: unauthorized
              dev: 40100
              message: Missing or invalid Authorization Bearer token.
    Forbidden:
      description: Caller type not allowed for this endpoint.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            status: 403
            error:
              type: permission_error
              code: forbidden
              dev: 40300
              message: You don't have permission for this action.
    RateLimited:
      description: Too many requests.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            status: 429
            error:
              type: rate_limit_error
              code: rate_limited
              dev: 42900
              message: You're doing that too often. Please wait a moment.
    ServerError:
      description: Unexpected server error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            status: 500
            error:
              type: system_error
              code: internal_error
              dev: 50000
              message: Something went wrong on our end.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >
        Supabase user JWT (or an internal service token). Send as
        `Authorization: Bearer <token>`.

````

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