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

# /v1/upload

> Upload data to the Parser Expert API. You can upload either a file or provide a webpage URL.



## OpenAPI

````yaml POST /v1/upload
openapi: 3.0.1
info:
  title: Parser Expert API
  description: API documentation for Parser Expert.
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.parser.expert
security:
  - apiKeyAuth: []
paths:
  /v1/upload:
    post:
      summary: Upload Data
      description: >-
        Upload data to the Parser Expert API. You can upload either a file or
        provide a webpage URL.
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
                  description: >-
                    The file to upload. Supported formats are PDF, DOCX, Image,
                    Txt File (maximum of 10 pages per document).
                bucket_id:
                  type: string
                  description: >-
                    The ID of the bucket where the data will be stored.Refer to
                    Quickstart for set extraction fields
                webpage_url:
                  type: string
                  description: >-
                    The URL of the webpage to extract content from. This will be
                    ignored if `file` is provided.
              required:
                - bucket_id
      responses:
        '200':
          description: Extract upserted successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      parser_id:
                        type: string
                        description: The ID of the parser.
                  message:
                    type: string
                    description: Success message.
              example:
                data:
                  parser_id: f555c13a-846f-4505-95fe-8f72b39edef9
                message: Extract upserted successfully
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '405':
          $ref: '#/components/responses/MethodNotAllowed'
        '424':
          $ref: '#/components/responses/FailedDependency'
        '500':
          $ref: '#/components/responses/InternalServerError'
      x-codeSamples:
        - lang: Python
          source: |-
            import requests

            url = "https://api.parser.expert/v1/upload"

            headers = {
                'X-API-Key': 'sk-xxxx'
            }

            files = {
                'file': open('/path/to/your/file.pdf', 'rb'),
                'bucket_id': (None, '100202')
            }

            response = requests.post(url, headers=headers, files=files)

            print(response.text)
        - lang: Go
          source: |-
            package main

            import (
                "bytes"
                "fmt"
                "mime/multipart"
                "net/http"
                "os"
            )

            func main() {
                url := "https://api.parser.expert/v1/upload"
                apiKey := "sk-xxxxxxxx"
                filePath := "/path/to/your/file.pdf"

                file, err := os.Open(filePath)
                if err != nil {
                    panic(err)
                }
                defer file.Close()

                body := &bytes.Buffer{}
                writer := multipart.NewWriter(body)
                part, err := writer.CreateFormFile("file", "file.pdf")
                if err != nil {
                    panic(err)
                }
                _, err = io.Copy(part, file)
                if err != nil {
                    panic(err)
                }

                _ = writer.WriteField("bucket_id", "100202")
                writer.Close()

                req, err := http.NewRequest("POST", url, body)
                if err != nil {
                    panic(err)
                }
                req.Header.Add("X-API-Key", apiKey)
                req.Header.Set("Content-Type", writer.FormDataContentType())

                client := &http.Client{}
                resp, err := client.Do(req)
                if err != nil {
                    panic(err)
                }
                defer resp.Body.Close()

                fmt.Println("Response Status:", resp.Status)
            }
        - lang: Curl
          source: >-
            curl --location --request POST 'https://api.parser.expert/v1/upload'
            \

            --header 'X-API-Key: sk-xxxxxxxx' \

            --form 'file=@"/path/to/your/file.pdf"' \

            --form 'bucket_id="100202"'
        - lang: Java
          source: |-
            import java.io.File;
            import java.io.FileInputStream;
            import java.io.IOException;
            import java.io.OutputStream;
            import java.net.HttpURLConnection;
            import java.net.URL;

            public class UploadFile {
                public static void main(String[] args) throws IOException {
                    String url = "https://api.parser.expert/v1/upload";
                    String apiKey = "sk-xxxxxxxx";
                    String boundary = "Boundary-" + System.currentTimeMillis();
                    String lineEnd = "\r\n";
                    String twoHyphens = "--";

                    HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
                    connection.setDoOutput(true);
                    connection.setRequestMethod("POST");
                    connection.setRequestProperty("X-API-Key", apiKey);
                    connection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);

                    OutputStream outputStream = connection.getOutputStream();

                    // File part
                    outputStream.write((twoHyphens + boundary + lineEnd).getBytes());
                    outputStream.write("Content-Disposition: form-data; name=\"file\"; filename=\"file.pdf\"".getBytes());
                    outputStream.write(lineEnd.getBytes());
                    outputStream.write("Content-Type: application/pdf".getBytes());
                    outputStream.write(lineEnd.getBytes());
                    outputStream.write(lineEnd.getBytes());

                    FileInputStream fileInputStream = new FileInputStream(new File("/path/to/your/file.pdf"));
                    int bytesRead;
                    byte[] buffer = new byte[4096];
                    while ((bytesRead = fileInputStream.read(buffer)) != -1) {
                        outputStream.write(buffer, 0, bytesRead);
                    }
                    outputStream.write(lineEnd.getBytes());

                    // bucket_id part
                    outputStream.write((twoHyphens + boundary + lineEnd).getBytes());
                    outputStream.write("Content-Disposition: form-data; name=\"bucket_id\"".getBytes());
                    outputStream.write(lineEnd.getBytes());
                    outputStream.write(lineEnd.getBytes());
                    outputStream.write("100202".getBytes());
                    outputStream.write(lineEnd.getBytes());

                    // End part
                    outputStream.write((twoHyphens + boundary + twoHyphens + lineEnd).getBytes());
                    outputStream.flush();
                    outputStream.close();

                    int responseCode = connection.getResponseCode();
                    System.out.println("Response Code: " + responseCode);
                }
            }
        - lang: JavaScript
          source: |-
            const axios = require('axios');
            const FormData = require('form-data');
            const fs = require('fs');

            const url = 'https://api.parser.expert/v1/upload';
            const apiKey = 'sk-xxxxxxxx';
            const filePath = '/path/to/your/file.pdf';

            const form = new FormData();
            form.append('file', fs.createReadStream(filePath));
            form.append('bucket_id', '100202');

            axios.post(url, form, {
                headers: {
                    'X-API-Key': apiKey,
                    ...form.getHeaders()
                }
            }).then(response => {
                console.log(response.data);
            }).catch(error => {
                console.error(error);
            });
        - lang: PHP
          source: >-
            <?php


            $apiKey = 'sk-xxxxxxxx';

            $filePath = '/path/to/your/file.pdf';


            $ch = curl_init();


            curl_setopt($ch, CURLOPT_URL,
            'https://api.parser.expert/v1/upload');

            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);


            $post = array(
                'file' => new CURLFile($filePath),
                'bucket_id' => '100202'
            );

            $headers = array(
                'X-API-Key: ' . $apiKey
            );


            curl_setopt($ch, CURLOPT_POSTFIELDS, $post);

            curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);


            $response = curl_exec($ch);

            if (curl_errno($ch)) {
                echo 'Error:' . curl_error($ch);
            }


            curl_close($ch);


            echo $response;

            ?>
components:
  responses:
    BadRequest:
      description: Bad Request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: Forbidden
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Not Found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    MethodNotAllowed:
      description: Method Not Allowed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    FailedDependency:
      description: Failed Dependency
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    InternalServerError:
      description: Internal Server Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key

````