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

# Get Signed Upload URL

> Generate a pair of presigned URLs: one for uploading a PDF file to temporary storage and one for downloading it.

GET [https://api.pdfnoodle.com/v1/tools/get-signed-upload-url](https://api.pdfnoodle.com/v1/tools/get-signed-upload-url)

## Request

<CodeGroup>
  ```bash cURL theme={null}
  curl --location 'https://api.pdfnoodle.com/v1/tools/get-signed-upload-url?fileName=my-document.pdf' \
  --header 'Authorization: Bearer pdfnoodle_api_123456789'
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch(
    "https://api.pdfnoodle.com/v1/tools/get-signed-upload-url?fileName=my-document.pdf",
    {
      method: "GET",
      headers: {
        Authorization: "Bearer pdfnoodle_api_123456789",
      },
    }
  );

  const result = await response.json();
  ```

  ```python Python theme={null}
  import requests

  response = requests.get(
      'https://api.pdfnoodle.com/v1/tools/get-signed-upload-url',
      headers={
          'Authorization': 'Bearer pdfnoodle_api_123456789'
      },
      params={
          'fileName': 'my-document.pdf'
      }
  )

  result = response.json()
  ```
</CodeGroup>

## Response

<CodeGroup>
  ```json Success (200 OK) theme={null}
  {
    "presignedUploadUrl": "https://s3.amazonaws.com/...",
    "presignedGetUrl": "https://s3.amazonaws.com/...",
    "status": "SUCCESS",
    "fileName": "my-document.pdf",
    "uploadUrlValidUntil": "2025-01-01T01:30:00.000Z",
    "getUrlValidUntil": "2025-01-01T02:00:00.000Z"
  }
  ```

  ```json Error (400 Bad Request) theme={null}
  {
    "message": "Couldnt identify company"
  }
  ```
</CodeGroup>

The `presignedUploadUrl` is a temporary URL you can use to upload your PDF file via a `PUT` request. The `presignedGetUrl` is a temporary URL you can use to download the uploaded file.

* **Upload URL** expires in **30 minutes**
* **Download URL** expires in **60 minutes**

<Info>
  If no `fileName` is provided, a random filename will be generated automatically. Filenames are sanitized to only allow alphanumeric characters, dots, hyphens, and underscores.
</Info>

### Uploading a file using the presigned URL

Once you have the `presignedUploadUrl`, you can upload your PDF file using a `PUT` request:

<CodeGroup>
  ```bash cURL theme={null}
  curl --request PUT \
    --url 'YOUR_PRESIGNED_UPLOAD_URL' \
    --header 'Content-Type: application/pdf' \
    --data-binary '@/path/to/your/file.pdf'
  ```

  ```javascript JavaScript theme={null}
  const fileBuffer = fs.readFileSync("/path/to/your/file.pdf");

  await fetch("YOUR_PRESIGNED_UPLOAD_URL", {
    method: "PUT",
    headers: {
      "Content-Type": "application/pdf",
    },
    body: fileBuffer,
  });
  ```

  ```python Python theme={null}
  with open('/path/to/your/file.pdf', 'rb') as f:
      requests.put(
          'YOUR_PRESIGNED_UPLOAD_URL',
          headers={'Content-Type': 'application/pdf'},
          data=f.read()
      )
  ```
</CodeGroup>

### Accessing the uploaded file

After uploading, use the `presignedGetUrl` from the original response to download or access the file:

<CodeGroup>
  ```bash cURL theme={null}
  curl --location 'YOUR_PRESIGNED_GET_URL' --output downloaded-file.pdf
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch("YOUR_PRESIGNED_GET_URL");
  const blob = await response.blob();

  // Save to file (Node.js)
  const buffer = Buffer.from(await blob.arrayBuffer());
  fs.writeFileSync("downloaded-file.pdf", buffer);
  ```

  ```python Python theme={null}
  response = requests.get('YOUR_PRESIGNED_GET_URL')

  with open('downloaded-file.pdf', 'wb') as f:
      f.write(response.content)
  ```
</CodeGroup>

<Info>
  The `presignedGetUrl` is also the URL you should pass as the `url` parameter to other PDF Tools endpoints (such as [Merge PDFs](/api-reference/tools/merge-pdfs), [Split PDF](/api-reference/tools/split-pdf), [Compress PDF](/api-reference/tools/compress-pdf), or [Update PDF Metadata](/api-reference/tools/update-pdf-metadata)) when you want to process the uploaded file.
</Info>

## Parameters

<ParamField query="fileName" type="string">
  The desired filename for the uploaded PDF. If not provided, a random name will
  be generated. Special characters will be replaced with underscores.
</ParamField>
