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

# Create File

> Create an entity (file/blob) that is a file in the system.

#### Recipe

<AccordionGroup>
  <Accordion title="Create a public file">
    <Steps>
      <Step title="1. Use a `blob` parameter to set blob fields">
        ```curl {5-6} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: f8dd521e8a88b0df7e0c359dc3de73fc15012bba" \
        -d '{  
          "blob":{  
          }
        }' \
        https://api.quickblox.com/blobs.json
        ```
      </Step>

      <Step title="2. Set a content type of the file">
        Use a `content-type` parameter to set a content type of the file.

        ```curl {6} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: f8dd521e8a88b0df7e0c359dc3de73fc15012bba" \
        -d '{  
          "blob":{  
            "content_type":"image/jpeg",
          }
        }' \
        https://api.quickblox.com/blobs.json
        ```
      </Step>

      <Step title="3. Set a name of the file">
        Use a `name` parameter to set the name of the file.

        ```curl {7} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: f8dd521e8a88b0df7e0c359dc3de73fc15012bba" \
        -d '{  
          "blob":{  
            "content_type":"image/jpeg",
            "name":"my_cat.jpeg",
          }
        }' \
        https://api.quickblox.com/blobs.json
        ```
      </Step>

      <Step title="4. Set a file as public">
        Set a `public` parameter as true to make a file public.

        ```curl {8} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: f8dd521e8a88b0df7e0c359dc3de73fc15012bba" \
        -d '{  
          "blob":{  
            "content_type":"image/jpeg",
            "name":"my_cat.jpeg",
            "public":true,
          }
        }' \
        https://api.quickblox.com/blobs.json
        ```
      </Step>

      <Step title="5. Set tags to a file">
        Use a `tag_list` to assign tags to a file.

        ```curl {9} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: f8dd521e8a88b0df7e0c359dc3de73fc15012bba" \
        -d '{  
          "blob":{  
            "content_type":"image/jpeg",
            "name":"my_cat.jpeg",
            "public":true,
            "tag_list":"web,android"
          }
        }' \
        https://api.quickblox.com/blobs.json
        ```
      </Step>

      <Step title="6. As a result, the API returns a newly created public file.">
        ```json theme={null}
        {
          "blob": {
            "id": 10070416,
            "uid": "20456a9676674f4ca950d963dfca630e00",
            "content_type": "image/jpeg",
            "name": "my_cat.jpeg",
            "size": null,
            "created_at": "2020-07-29T11:06:31Z",
            "updated_at": "2020-07-29T11:06:31Z",
            "blob_status": null,
            "set_completed_at": null,
            "public": true,
            "account_id": 105726,
            "app_id": 78162,
            "blob_object_access": {
              "id": 10070416,
              "blob_id": 10070416,
              "expires": "2020-07-29T12:06:31Z",
              "object_access_type": "Write",
              "params": "https://api.quickblox.com/blobs/10070416/upload/?acl=authenticated-read&content_type=image%2Fjpeg&expires=2020-07-29%2012%3A06%3A31%20UTC&key=20456a9676674f4ca950d963dfca630e00&policy=OTVhNDNiZDNiMWMxMGZlNDgzMmE1MzEyYzE4MjYyZjI%3D%0A&success_action_status=201&x-amz-algorithm=AWS4-HMAC-SHA256&x-amz-credential=d9edd8e29a9f029549ecf6313c67c676%2F20200729%2Fqbprod%2Fs3%2Faws4_request&x-amz-date=2020211T1206Z&x-amz-signature=84901614d08e3d2d1fbba76dc5378242"
            }
          }
        }
        ```
      </Step>
    </Steps>
  </Accordion>

  <Accordion title="Create a private file">
    <Steps>
      <Step title="1. Use a `blob` parameter to set blob fields">
        ```curl {5-6} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: f8dd521e8a88b0df7e0c359dc3de73fc15012bba" \
        -d '{  
          "blob":{  
          }
        }' \
        https://api.quickblox.com/blobs.json
        ```
      </Step>

      <Step title="2. Set a content type of the file">
        Use a `content-type` parameter to set a content type of the file.

        ```curl {6} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: f8dd521e8a88b0df7e0c359dc3de73fc15012bba" \
        -d '{  
          "blob":{
            "content_type":"image/jpeg",  
          }
        }' \
        https://api.quickblox.com/blobs.json
        ```
      </Step>

      <Step title="3. Set a name of the file">
        Use a `name` parameter to set the name of the file.

        ```curl {7} theme={null}
        curl -X POST \
        -H "Content-Type: application/json" \
        -H "QB-Token: f8dd521e8a88b0df7e0c359dc3de73fc15012bba" \
        -d '{  
          "blob":{
            "content_type":"image/jpeg",
            "name":"museum.jpeg"  
          }
        }' \
        https://api.quickblox.com/blobs.json
        ```
      </Step>

      <Step title="4. As a result, the API returns a newly created private file.">
        ```json theme={null}
        {
          "blob": {
            "id": 10070416,
            "uid": "20456a9676674f4ca950d963dfca630e00",
            "content_type": "image/jpeg",
            "name": "museum.jpeg",
            "size": null,
            "created_at": "2020-07-29T11:06:31Z",
            "updated_at": "2020-07-29T11:06:31Z",
            "blob_status": null,
            "set_completed_at": null,
            "public": false,
            "account_id": 105726,
            "app_id": 78162,
            "blob_object_access": {
              "id": 10070416,
              "blob_id": 10070416,
              "expires": "2020-07-29T12:06:31Z",
              "object_access_type": "Write",
              "params": "https://api.quickblox.com/blobs/10070416/upload/?acl=authenticated-read&content_type=image%2Fjpeg&expires=2020-07-29%2012%3A06%3A31%20UTC&key=20456a9676674f4ca950d963dfca630e00&policy=OTVhNDNiZDNiMWMxMGZlNDgzMmE1MzEyYzE4MjYyZjI%3D%0A&success_action_status=201&x-amz-algorithm=AWS4-HMAC-SHA256&x-amz-credential=d9edd8e29a9f029549ecf6313c67c676%2F20200729%2Fqbprod%2Fs3%2Faws4_request&x-amz-date=2020211T1206Z&x-amz-signature=84901614d08e3d2d1fbba76dc5378242"
            }
          }
        }
        ```
      </Step>
    </Steps>
  </Accordion>
</AccordionGroup>

#### Body Parameters

<ParamField body="blob" type="object" required>
  <Expandable title="properties">
    <ParamField body="content_type" type="string" required>
      <Tooltip tip="MIME content type - Multipurpose Internet Mail Extensions (MIME) is an Internet standard extending the format of email messages by supporting text in character sets other than ASCII, and attachments such as audio, video, images, and application programs."> MIME content type</Tooltip>
    </ParamField>

    <ParamField body="name" type="string" required>File/blob name</ParamField>

    <ParamField body="public" type="string" default="false">
      File/blob visibility. If the file is public, it's possible to download it without a session token.
    </ParamField>

    <ParamField body="tag_list" type="string">Should be a comma-separated string with tags.</ParamField>
  </Expandable>
</ParamField>

#### Headers

<ParamField header="QB-Token" type="string" required> A user or application session token. See [Authentication](/reference/authentication) page to learn more about session tokens. Must be used either QB-Token or Authorization. </ParamField>

#### Responses

<AccordionGroup>
  <Accordion title="201">
    A successful response

    <ResponseField name="blob" type="object">
      <Expandable title="properties">
        <ResponseField name="id" type="integer" />

        <ResponseField name="uid" type="string" />

        <ResponseField name="content_type" type="string" />

        <ResponseField name="name" type="string" />

        <ResponseField name="size" type="string" />

        <ResponseField name="created_at" type="string" />

        <ResponseField name="updated_at" type="string" />

        <ResponseField name="blob_status" type="string" />

        <ResponseField name="set_completed_at" type="string" />

        <ResponseField name="public" type="boolean" />

        <ResponseField name="account_id" type="integer" />

        <ResponseField name="app_id" type="integer" />

        <ResponseField name="blob_object_access" type="object">
          <Expandable title="properties">
            <ResponseField name="id" type="integer" />

            <ResponseField name="blob_id" type="integer" />

            <ResponseField name="expires" type="string" />

            <ResponseField name="object_access_type" type="string" />

            <ResponseField name="params" type="string" />
          </Expandable>
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Accordion>

  <Accordion title="422">
    An error response

    <ResponseField name="errors" type="object">
      <Expandable title="properties">
        <ResponseField name="name" type="array of strings" />

        <ResponseField name="content_type" type="array of strings" />
      </Expandable>
    </ResponseField>
  </Accordion>
</AccordionGroup>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST \
  -H "Content-Type: application/json" \
  -H "QB-Token: 2e80acd7f3d9c1e79312e0d1dafd6691ba012bba" \
  -d '{  
    "blob":{  
      "content_type":"image/jpeg",
      "name":"museum.jpeg"
    }
  }' \
  https://api.quickblox.com/blobs.json
  ```
</RequestExample>

<ResponseExample>
  ```json 201 theme={null}
  {
    "blob": {
      "id": 10070416,
      "uid": "20456a9676674f4ca950d963dfca630e00",
      "content_type": "image/jpeg",
      "name": "test2.jpg",
      "size": null,
      "created_at": "2020-07-29T11:06:31Z",
      "updated_at": "2020-07-29T11:06:31Z",
      "blob_status": null,
      "set_completed_at": null,
      "public": false,
      "account_id": 105726,
      "app_id": 78162,
      "blob_object_access": {
        "id": 10070416,
        "blob_id": 10070416,
        "expires": "2020-07-29T12:06:31Z",
        "object_access_type": "Write",
        "params": "https://api.quickblox.com/blobs/10070416/upload/?acl=authenticated-read&content_type=image%2Fjpeg&expires=2020-07-29%2012%3A06%3A31%20UTC&key=20456a9676674f4ca950d963dfca630e00&policy=OTVhNDNiZDNiMWMxMGZlNDgzMmE1MzEyYzE4MjYyZjI%3D%0A&success_action_status=201&x-amz-algorithm=AWS4-HMAC-SHA256&x-amz-credential=d9edd8e29a9f029549ecf6313c67c676%2F20200729%2Fqbprod%2Fs3%2Faws4_request&x-amz-date=2020211T1206Z&x-amz-signature=84901614d08e3d2d1fbba76dc5378242"
      }
    }
  }
  ```

  ```json 422 theme={null}
  {
    "errors": {
      "name": [
        "can't be blank",
        "is too short (minimum is 1 character)",
        "is too long (maximum is 100 characters)"
      ],
      "content_type": [
        "is invalid",
        "is too short (minimum is 5 characters)",
        "is too long (maximum is 100 characters)"
      ]
    }
  }
  ```
</ResponseExample>
