---
updatedAt: 2025-06-11T20:22:12.000Z
agentTools:
  projectIndex: https://docs.finbits.com.br/llms.txt
---

# Criar Anexo

Esta rota permite criar um anexo na plataforma Finbits.

## Exemplo de código em JavaScript:

```javascript
const formData = new FormData();

formData.append("file", fileInput.files[0], "example.txt");

fetch("https://api.finbits.com.br/public/attachments", {
  method: "POST",
  headers: {
    authorization: `Bearer ${FINBITS_PUBLIC_API_TOKEN}`
  },
  body: formData
}).then(response => response.json())
  .then(data => console.log(data));
```

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "finbits-api",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.finbits.com.br/public"
    }
  ],
  "components": {
    "securitySchemes": {
      "sec0": {
        "type": "oauth2",
        "flows": {}
      }
    }
  },
  "security": [
    {
      "sec0": []
    }
  ],
  "paths": {
    "/attachments": {
      "post": {
        "summary": "Criar Anexo",
        "description": "Esta rota permite criar um anexo na plataforma Finbits.",
        "operationId": "criar-anexo",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "description": "Arquivo de um dos seguintes tipos: Imagem, PDF, Planilha do Excel, XML, ou texto",
                    "format": "binary"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "200",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "{\n   \"id\":\"attachment_epk42mf5afekle3tujvcfl76ui\",\n   \"name\":\"attachment_56.jpg\",\n   \"type\":\"image/jpeg\",\n   \"object\":\"attachment\"\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "example": "attachment_epk42mf5afekle3tujvcfl76ui"
                    },
                    "name": {
                      "type": "string",
                      "example": "attachment_56.jpg"
                    },
                    "type": {
                      "type": "string",
                      "example": "image/jpeg"
                    },
                    "object": {
                      "type": "string",
                      "example": "attachment"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "401",
            "content": {
              "text/plain": {
                "examples": {
                  "Result": {
                    "value": ""
                  }
                }
              }
            }
          },
          "422": {
            "description": "422",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "{\"errors\":{\"type\":[\"has invalid content type\"]},\"message\":\"Unprocessable entity\"}"
                  }
                },
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "errors": {
                          "type": "object",
                          "properties": {
                            "file": {
                              "type": "string",
                              "example": "could not upload"
                            }
                          }
                        },
                        "message": {
                          "type": "string",
                          "example": "Unprocessable entity"
                        }
                      }
                    },
                    {
                      "type": "object",
                      "properties": {
                        "errors": {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "example": "has invalid content type"
                              }
                            }
                          }
                        },
                        "message": {
                          "type": "string",
                          "example": "Unprocessable entity"
                        }
                      }
                    }
                  ]
                }
              }
            }
          }
        },
        "deprecated": false
      }
    }
  },
  "x-readme": {
    "headers": [],
    "explorer-enabled": true,
    "proxy-enabled": true
  },
  "x-readme-fauxas": true
}
```