---
title: Create a File
slug: create-a-file
docTags: 
createdAt: 2026-04-21T15:22:49.957Z
---

{
  "id": "EK8My_DJTDnwbLguZqjUN",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "https://developer.digitail.io/api/v1/files",
    "servers": [
      {
        "url": "https://developer.digitail.io/api/v1/files",
        "description": "Sandbox server (uses test data)"
      },
      {
        "url": "https://vet.digitail.io/api/v1/files",
        "description": "Production server (uses live data)"
      }
    ],
    "name": "Create a File",
    "description": "<p>Permissions needed: ACCESS_PATIENTS\nUpload a new file and attach it to a pet</p>",
    "contentType": "multipart/form-data",
    "request": {
      "pathParameters": [],
      "headerParameters": [
        {
          "name": "accept",
          "type": "string",
          "kind": "optional",
          "description": "Generated from available response content types",
          "enum": [
            "application/json"
          ],
          "default": "application/json"
        }
      ],
      "queryParameters": [],
      "bodyDataParameters": [],
      "formDataParameters": [
        {
          "name": "payload",
          "kind": "optional",
          "type": "object",
          "description": "send it as a stringified JSON",
          "example": "",
          "schema": [
            {
              "name": "pet_id",
              "kind": "optional",
              "type": "integer",
              "description": "",
              "example": 1
            },
            {
              "name": "record_id",
              "kind": "optional",
              "type": "integer",
              "description": "",
              "example": 1
            }
          ]
        },
        {
          "name": "file",
          "kind": "optional",
          "type": "string<binary>",
          "description": "",
          "format": "binary"
        }
      ],
      "oAuthParameters": [
        {
          "id": "passport",
          "name": "passport",
          "kind": "optional",
          "type": "oauth2",
          "description": "Laravel passport oauth2 security.",
          "oauth2Flows": {
            "authorizationCode": {
              "authorizationUrl": "https://digitail.test/oauth/authorize",
              "tokenUrl": "https://digitail.test/oauth/token",
              "refreshUrl": "https://digitail.test/oauth/token"
            }
          }
        },
        {
          "id": "Bearer",
          "name": "Bearer",
          "kind": "optional",
          "type": "http",
          "scheme": "bearer"
        }
      ],
      "cookieParameters": []
    },
    "responses": [
      {
        "statusCode": "201",
        "description": "successful operation",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "description": "",
            "schema": [
              {
                "name": "data",
                "kind": "optional",
                "type": "object",
                "description": "<p>A file that was uploaded to the system and that is linked to a pet. No more than 10MB in size. The file can be a photo, a document, a video, etc. A file can also be associated or not with a record.</p>",
                "example": "",
                "schema": [
                  {
                    "name": "id",
                    "kind": "optional",
                    "type": "integer",
                    "description": "",
                    "example": 1
                  },
                  {
                    "name": "pet_id",
                    "kind": "optional",
                    "type": "integer",
                    "description": "",
                    "example": 1
                  },
                  {
                    "name": "clinic_id",
                    "kind": "optional",
                    "type": "integer",
                    "description": "",
                    "example": 766
                  },
                  {
                    "name": "file_id",
                    "kind": "optional",
                    "type": "integer",
                    "nullable": true,
                    "description": "The id of the record that the uploaded file is associated to.",
                    "example": ""
                  },
                  {
                    "name": "name",
                    "kind": "optional",
                    "type": "string",
                    "description": "",
                    "example": "image.jpg"
                  },
                  {
                    "name": "name_without_extension",
                    "kind": "optional",
                    "type": "string",
                    "description": "",
                    "example": "image"
                  },
                  {
                    "name": "extension",
                    "kind": "optional",
                    "type": "string",
                    "description": "",
                    "example": "jpg"
                  },
                  {
                    "name": "thumbnail",
                    "kind": "optional",
                    "type": "string",
                    "description": "",
                    "example": "https://vet.digitail.io/images/files/jpg.svg"
                  },
                  {
                    "name": "updated_at",
                    "kind": "optional",
                    "type": "string<date-time>",
                    "description": "",
                    "example": "2021-10-05T12:52:53.000000Z",
                    "format": "date-time"
                  },
                  {
                    "name": "download_url",
                    "kind": "optional",
                    "type": "string",
                    "description": "",
                    "example": "https://vet.digitail.io/api/v1/files/1/download"
                  },
                  {
                    "name": "preview_url",
                    "kind": "optional",
                    "type": "string",
                    "description": "",
                    "example": "https://vet.digitail.io/api/v1/files/1/preview"
                  }
                ]
              }
            ],
            "isExpanded": true
          }
        ]
      }
    ],
    "hasXCodeSamples": false,
    "examples": {
      "languages": [
        {
          "id": "Rxp6Zf19r0AAZGJlqNyHJ",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url https://developer.digitail.io/api/v1/files \\\n     --header 'accept: application/json' \\\n     --header 'content-type: multipart/form-data' \\\n     --form 'payload=\"object\"'"
        },
        {
          "id": "BmUmH-BM7MR8RIiDL0ueX",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"multipart/form-data\");\n\nvar formdata = new FormData();\nformdata.append(\"payload\", \"object\");\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: formdata,\n   redirect: 'follow'\n};\n\nfetch(\"https://developer.digitail.io/api/v1/files\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "GWtPAopq_xh1WfkmhGb14",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"net/http\"\n\nurl = URI(\"https://developer.digitail.io/api/v1/files\")\n\nhttps = Net::HTTP.new(url.host, url.port)\nhttps.use_ssl = true\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"multipart/form-data\"\nform_data = [['payload', File.open('undefined')]]\nrequest.set_form form_data, 'multipart/form-data'\nresponse = https.request(request)\nputs response.read_body\n"
        },
        {
          "id": "8SFKL3viPNVbq-yNcEqaB",
          "language": "python",
          "label": "Python",
          "code": "import requests\n\nurl = \"https://developer.digitail.io/api/v1/files\"\n\npayload = {}\nfiles=[\n\n]\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'multipart/form-data'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload, files=files)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "Rxp6Zf19r0AAZGJlqNyHJ"
    },
    "results": {
      "languages": [
        {
          "id": "G_valPwiM1ack2aUjWsnG",
          "language": "201",
          "code": "// successful operation\n{\n  \"data\": {\n    \"id\": 1,\n    \"pet_id\": 1,\n    \"clinic_id\": 766,\n    \"file_id\": 0,\n    \"name\": \"image.jpg\",\n    \"name_without_extension\": \"image\",\n    \"extension\": \"jpg\",\n    \"thumbnail\": \"https://vet.digitail.io/images/files/jpg.svg\",\n    \"updated_at\": \"2021-10-05T12:52:53.000000Z\",\n    \"download_url\": \"https://vet.digitail.io/api/v1/files/1/download\",\n    \"preview_url\": \"https://vet.digitail.io/api/v1/files/1/preview\"\n  }\n}"
        }
      ],
      "selectedLanguageId": "G_valPwiM1ack2aUjWsnG"
    }
  },
  "children": [
    {
      "text": ""
    }
  ]
}