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

# Create a resource

> Creates a resource. With `url`, creates a link-type file; otherwise creates a pending upload and returns a signed `upload_url` to stream the file into R2.



## OpenAPI

````yaml /api-reference/openapi.generated.json post /api/resources
openapi: 3.1.0
info:
  title: Empirical API
  version: 1.0.0
  description: Programmatic access to Empirical test runs, snoozes, and more.
  contact:
    name: Empirical
    url: https://empirical.run
servers:
  - url: https://api.empirical.run
security:
  - Bearer: []
tags:
  - name: Test Runs
    description: Trigger, list, and inspect end-to-end test runs.
  - name: Test Cases
    description: >-
      Browse the Playwright test cases synced from a project's repository and
      manage their tags.
  - name: Environments
    description: >-
      Named deployment targets (slug + Playwright project filters) a project's
      tests run against.
  - name: Snoozes
    description: Temporarily suppress known test failures for specific Playwright tests.
  - name: Analytics
    description: Aggregated test-run, test-count and test-case analytics for a project.
  - name: Resources
    description: >-
      Project file resources — uploads stored in R2 and external link-type files
      (e.g. Google Sheets).
  - name: Badges
    description: Public README status badge images (SVG) for project environments.
paths:
  /api/resources:
    post:
      tags:
        - Resources
      summary: Create a resource
      description: >-
        Creates a resource. With `url`, creates a link-type file; otherwise
        creates a pending upload and returns a signed `upload_url` to stream the
        file into R2.
      operationId: createProjectResource
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateProjectResourceRequest'
      responses:
        '200':
          description: The created resource, including an `upload_url`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateProjectResourceResponse'
        '400':
          description: Invalid request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    CreateProjectResourceRequest:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          description: Display name for the file.
        mime_type:
          type: string
          description: MIME type of the file.
        size_bytes:
          type: number
          description: File size in bytes.
        url:
          type: string
          description: >-
            External URL (e.g. a Google Sheet link). When provided, creates a
            link-type file with no R2 upload.
        description:
          type: string
          description: Description for the file.
      required:
        - name
    CreateProjectResourceResponse:
      type: object
      properties:
        data:
          type: object
          properties:
            resource:
              $ref: '#/components/schemas/ResourceWithUploadUrl'
          required:
            - resource
          description: Response payload.
      required:
        - data
    ErrorResponse:
      type: object
      properties:
        data:
          nullable: true
          description: Always null for error responses.
        error:
          type: object
          properties:
            message:
              type: string
              description: Human-readable error message.
          required:
            - message
          description: Error details.
      required:
        - data
        - error
    ResourceWithUploadUrl:
      type: object
      properties:
        id:
          type: number
          description: Unique identifier.
        name:
          type: string
          description: File name.
        url:
          type: string
          description: >-
            Download URL. For uploaded files, a signed URL that expires in 1
            hour. For link-type files, the stored external URL.
        description:
          type: string
          nullable: true
          description: Resource description.
        mime_type:
          type: string
          nullable: true
          description: MIME type.
        size_bytes:
          type: number
          nullable: true
          description: File size in bytes.
        status:
          type: string
          enum:
            - pending
            - uploaded
          description: '`pending` until confirmed via PATCH, then `uploaded`.'
        access_level:
          type: string
          nullable: true
          description: >-
            For link-type files (e.g. Google Sheets): "read_write", "read", or
            "none". Null for uploaded files.
        created_by:
          type: string
          nullable: true
          description: User ID of the creator.
        created_at:
          type: string
          description: ISO 8601 timestamp.
        updated_at:
          type: string
          description: ISO 8601 timestamp.
        upload_url:
          type: string
          description: Presigned URL for uploading the file via PUT. Expires in 1 hour.
      required:
        - id
        - name
        - url
        - description
        - mime_type
        - size_bytes
        - status
        - access_level
        - created_by
        - created_at
        - updated_at
        - upload_url
  securitySchemes:
    Bearer:
      type: http
      scheme: bearer

````