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

# Create Resource



## OpenAPI

````yaml POST /v1/resources
openapi: 3.1.0
info:
  title: re-factor API Reference
  version: 1.0.0
  description: API specification for re-factor system based on schema definitions
servers: []
security:
  - BearerAuth: []
paths:
  /v1/resources:
    post:
      summary: Create a new resource
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ResourceCreate'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Resource'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '409':
          $ref: '#/components/responses/ConflictError'
        '500':
          $ref: '#/components/responses/InternalError'
components:
  schemas:
    ResourceCreate:
      type: object
      required:
        - name
        - directory_path
      properties:
        content:
          type: string
          description: >-
            The file to upload. This can be provided instead of `uri`. It should
            be a base64-encoded string of the format
            `data:<MIME_TYPE>;base64,<BASE64_ENCODED_CONTENT>`.
        uri:
          type: string
          format: uri
          description: >-
            The URI of the file to upload. This can be provided instead of
            `content`.
        name:
          type: string
          description: Name of the resource
        tags:
          type: array
          items:
            type: string
          description: Tags for the resource
        directory_path:
          type: string
          description: Path to the directory where the resource should be stored
        metadata:
          type: object
          additionalProperties: true
          description: Additional metadata for the resource
    Resource:
      type: object
      required:
        - id
        - account_id
        - name
        - directory_path
        - mime_type
        - sha256
        - storage_bucket
        - storage_key
        - size_bytes
        - created_at
        - updated_at
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier for the resource
        account_id:
          type: string
          description: ID of the account that owns this resource
        name:
          type: string
          description: Name of the resource
        directory_path:
          type: string
          description: Path to the directory containing the resource
        mime_type:
          type: string
          description: MIME type of the resource
        sha256:
          type: string
          description: SHA256 hash of the resource content
        original_uri:
          type: string
          nullable: true
          description: Original URI of the resource, if applicable
        external_id:
          type: string
          nullable: true
          description: External identifier for the resource, if applicable
        external_storage_type:
          $ref: '#/components/schemas/ExternalStorageType'
          nullable: true
          description: Type of external storage, if applicable
        storage_bucket:
          type: string
          description: Storage bucket where the resource is stored
        storage_key:
          type: string
          description: Key for artifact storage in the storage system
        size_bytes:
          type: integer
          format: int64
          description: Size of the resource in bytes
        tags:
          type: array
          items:
            type: string
          description: >-
            List of tags associated with the resource. While stored in a
            separate table, this field represents the joined data.
        metadata:
          type: object
          nullable: true
          additionalProperties: true
          description: Additional metadata associated with the resource
        created_by:
          type: string
          nullable: true
          description: ID of the user who created the resource
        created_at:
          type: string
          format: date-time
          description: Timestamp when the resource was created
        updated_at:
          type: string
          format: date-time
          description: Timestamp when the resource was last updated
    ExternalStorageType:
      type: string
      enum:
        - s3
        - gcs
        - azure_blob
      description: Type of external storage provider
  responses:
    BadRequestError:
      description: Bad Request
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
    UnauthorizedError:
      description: Unauthorized
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
    ForbiddenError:
      description: Forbidden
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
    ConflictError:
      description: Conflict
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
    InternalError:
      description: Internal Server Error
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````