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

# Update Schema

> Update an existing schema



## OpenAPI

````yaml PUT /schemas/{id}
openapi: 3.0.3
info:
  title: Flora API Documentation
  description: >-
    Flora is an AI-powered API for unstructured data.


    ## The Flora API Key


    API is required to access the Flora API you should pass the key via the
    request header in this format: `Authorization: Bearer {{FLORA_API_KEY}}`


    To get your Flora API key, sign in to
    [https://withflora.io/](https://withflora.io/) and head to the API key
    section.


    ## Requests and Responses


    Request body and response data are formatted as JSON. Response Content-Type
    will always be `application/json`.


    It is recommended to use HTTP status codes to determine the result of an API
    call, however, each request response contains a `status` property which is
    either `true` when the request was successful or `false` when the request
    fails.


    ## Response Format


    **Status Code:** **`200`** will have data response in this format.


    ``` typescript

    {
        "status": true,
        "message": "Success message",
        "data": {...},
    }

     ```

    Requests with paginated response data will have an additional property
    called `meta` which contains the pagination info.  

    e.g.


    ``` typescript

    {
        "status": true,
        "message": "Operation successfully",
        "data": {
           "meta": {
              "total": 10,
              "perPage": 10,
              "currentPage": 1,
              "lastPage": 1,
              "firstPage": 1,
              "firstPageUrl": "/?page=1",
              "lastPageUrl": "/?page=1",
              "nextPageUrl": null,
              "previousPageUrl": null
           },
           "data": [...]
      },
    }

     ```

    **Status Code:** **`422`** Is returned when there is a request body
    validation error, below is an example response data.


    ``` typescript

    {

    "status": false,

    "errors": [
            {
                "field": "email",
                "message": "email is required to sign up"
            },
            {
                "field": "password",
                "message": "password is required to sign up"
            },
            ...
       ]
    }

     ```

    **Status Code:** **`401`**, **`403`**, and **`500`** response data will
    contain a `status` and `message` property. The message property gives an
    overview of the error.


    ``` typescript

    {
        "status": false,
        "message": "Unauthorized access"
    }

     ```

    ## Request Throttling


    **Status Code:** **`429`** response data will contain a `code` and `message`
    property. The message property gives an overview of the error.


    The request throttling is currently only applied to these endponts:


    \-


    ``` json

    {    
      "status": false
      "message": "Maximum number of requests exceeded. Please try again later.",
    }

     ```
  version: 1.0.0
  contact: {}
servers:
  - url: https://api.withflora.io/v1
security:
  - bearerAuth: []
tags:
  - name: Schemas
    description: >-
      The **Schema Endpoint** in **Flora's API** enables users to define
      structured data formats for extracting information from unstructured
      sources like images, PDFs, text, and webpages. This endpoint serves as the
      foundation for how extracted data is formatted and returned.


      #### **Key Functionalities:**


      - **Create a Schema:** Define a structured format, including required
      fields, data types, and validation rules.
          
      - **Retrieve Schemas:** Fetch existing schemas by ID or list all available
      schemas.
          
      - **Update a Schema:** Modify an existing schema to adapt to changing data
      needs.
          
      - **Delete a Schema:** Remove a schema that is no longer needed.
          

      #### **Usage Workflow:**


      1. **Define a Schema:** Specify the fields and structure in JSON format.
          
      2. **Use in Extraction Requests:** Pass the `schema_id` when sending data
      for processing.
          
      3. **Receive Structured Output:** Flora extracts and returns data based on
      the defined schema.
          

      ### Guide to Creating a Valid Schema


      This guide will help you create a valid schema. Follow the steps below to
      ensure your schema meets the necessary requirements.


      #### 1\. **Schema Structure**


      Your schema must be a valid JSON object with a specific structure. The
      root object should have a `type` field, which can be either `array` or
      `object`.


      #### 2\. **Array Type Schema**


      If the `type` is `array`, the schema must include an `items` field that
      defines the structure of the array elements.


      - **Items Field**: The `items` field must be an object with a `type`
      field, which can be either `object` or `array`.
          
      - **Object Type Items**: If the `items.type` is `object`, it must include
      a `properties` field that defines the fields of the object.
          
      - **Array Type Items**: If the `items.type` is `array`, it must include an
      `items` field to define the nested array structure.
          

      Example:


      ``` json

      {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "name": {
              "type": "string",
              "description": "The name of the item"
            },
            "price": {
              "type": "number",
              "description": "The price of the item"
            }
          }
        }
      }

       ```

      #### 3\. **Object Type Schema**


      If the `type` is `object`, the schema must include a `properties` field
      that defines the fields of the object.


      - **Properties Field**: The `properties` field must be an object where
      each key is a field name and the value is an object defining the field
      type and other attributes.
          

      Example:


      ``` json

      {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The name of the item"
          },
          "price": {
            "type": "number",
            "description": "The price of the item"
          }
        }
      }

       ```

      #### 4\. **Required Fields**


      You can specify required fields using the `required` attribute. For
      arrays, the `required` attribute can be used within the `items` field to
      specify required properties of the array elements.


      Example:


      ``` json

      {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The name of the item",
            "required": true
          },
          "price": {
            "type": "number",
            "description": "The price of the item"
          }
        }
      }

       ```
  - name: Extractions
    description: >-
      The **Extractions Endpoint** in **Flora's API** enables users to extract
      structured data from unstructured sources (images, PDFs, text, webpages)
      by supplying a **valid URL** and linking it to a predefined schema.


      #### **Key Functionalities:**


      - **Initiate an Extraction:** Submit a source URL along with a `schema_id`
      for processing.
          
      - **Retrieve Extracted Data:** Access structured data based on the
      provided schema.
          
      - **List All Extractions:** View a history of extractions and their
      statuses.
          
      - **Delete an Extraction:** Remove an extraction record when no longer
      needed.
          

      #### **Usage Workflow:**


      1. **Define a Schema:** Use the `/schemas` endpoint to create a structured
      format.
          
      2. **Submit an Extraction Request:** Provide:
          
          - `schema_id` (required) → ID of the schema to use.
              
          - `type` (required) → Input type (`image`, `pdf`, `text`, `webpage`).
              
          - `source` (required) → A **valid, accessible URL** pointing to the data.
              
          - `model` (optional) → Preferred AI model (`gpt-4.1`, `gpt-4.1-mini`).
              
          - `instruction` (optional) → Additional processing instructions.
              
      3. **Receive Extracted Data:** The API processes the source and returns
      structured output based on the schema.
          
      4. **Track Status (Optional):** Check request history and status if
      handling large volumes.
          

      **Authentication:**  
        
      Requires a valid API key via `Authorization: Bearer {token}`.


      This endpoint provides **a seamless way to extract structured data from
      online sources**, automating workflows and eliminating manual data
      processing.
paths:
  /schemas/{id}:
    parameters:
      - name: id
        in: path
        required: true
        schema:
          type: string
          example: c622793c-5e69-4670-bfa5-6e57b6fcbc74
    put:
      tags:
        - Schemas
      summary: update
      description: update
      operationId: update
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  example: News Articles
                structure:
                  type: object
                  properties:
                    items:
                      type: object
                      properties:
                        properties:
                          type: object
                          properties:
                            summary:
                              type: object
                              properties:
                                describe:
                                  type: string
                                  example: The news summary
                                type:
                                  type: string
                                  example: string
                            title:
                              type: object
                              properties:
                                describe:
                                  type: string
                                  example: The article title
                                type:
                                  type: string
                                  example: string
                        type:
                          type: string
                          example: object
                    required:
                      type: boolean
                      example: true
                    type:
                      type: string
                      example: array
            examples:
              update:
                value:
                  name: News Articles
                  structure:
                    items:
                      properties:
                        summary:
                          describe: The news summary
                          type: string
                        title:
                          describe: The article title
                          type: string
                      type: object
                    required: true
                    type: array
      responses:
        '200':
          description: '200'
          headers:
            Connection:
              schema:
                type: string
                example: keep-alive
            Date:
              schema:
                type: string
                example: Thu, 20 Mar 2025 21:16:00 GMT
            Keep-Alive:
              schema:
                type: string
                example: timeout=5
            content-length:
              schema:
                type: string
                example: '395'
            x-request-id:
              schema:
                type: string
                example: grhecxxalo6mv4qoc2696dyt
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      createdAt:
                        type: string
                        example: '2025-03-20T15:37:16.163+00:00'
                      description:
                        nullable: true
                        example: null
                      id:
                        type: string
                        example: 00f9190e-9a4a-4e08-ba00-f888437ed3c4
                      name:
                        type: string
                        example: News Articles
                      structure:
                        type: object
                        properties:
                          items:
                            type: object
                            properties:
                              properties:
                                type: object
                                properties:
                                  summary:
                                    type: object
                                    properties:
                                      describe:
                                        type: string
                                        example: The news summary
                                      type:
                                        type: string
                                        example: string
                                  title:
                                    type: object
                                    properties:
                                      describe:
                                        type: string
                                        example: The article title
                                      type:
                                        type: string
                                        example: string
                              type:
                                type: string
                                example: object
                          required:
                            type: boolean
                            example: true
                          type:
                            type: string
                            example: array
                  message:
                    type: string
                    example: Schema updated successfully
                  status:
                    type: boolean
                    example: true
              examples:
                '200':
                  value:
                    data:
                      createdAt: '2025-03-20T15:37:16.163+00:00'
                      id: 00f9190e-9a4a-4e08-ba00-f888437ed3c4
                      name: News Articles
                      structure:
                        items:
                          properties:
                            summary:
                              describe: The news summary
                              type: string
                            title:
                              describe: The article title
                              type: string
                          type: object
                        required: true
                        type: array
                    message: Schema updated successfully
                    status: true
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````

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