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

# Upload File into Media Storage

> If hosted is set to true then fileUrl is required. Else file is required. If adding a file, maximum allowed is 25 MB

If hosted is set to true then fileUrl is required. Else file is required. If adding a file, maximum allowed is 25 MB

```http theme={null}
POST https://services.leadconnectorhq.com/medias/upload-file
```

## Autorización

<ParamField header="Authorization" type="string" required>
  Bearer token generado desde el portal Leadway. Ver [Autenticación](/authentication).
</ParamField>

<ParamField header="Version" type="string" required default="2021-07-28">
  Versión de la API.
</ParamField>

## Body

<ParamField body="file" type="string" />

<ParamField body="hosted" type="boolean" />

<ParamField body="fileUrl" type="string" />

<ParamField body="name" type="string" />

<ParamField body="parentId" type="string" />

## Respuestas

<Accordion title="200 - Successful response">
  <ResponseField name="fileId" type="string" required default="file.pdf">
    ID of the uploaded file
  </ResponseField>

  <ResponseField name="url" type="string" required default="https://storage.googleapis.com/bucket-name/path/to/file.pdf">
    Google Cloud Storage URL of the uploaded file
  </ResponseField>

  ```json theme={null}
  {
    "fileId": "file.pdf",
    "url": "https://storage.googleapis.com/bucket-name/path/to/file.pdf"
  }
  ```
</Accordion>

## Ejemplo

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST 'https://services.leadconnectorhq.com/medias/upload-file' \
    -H 'Authorization: Bearer YOUR_TOKEN' \
    -H 'Version: 2021-07-28' \
    -H 'Content-Type: application/json' \
    -d '{
    "file": "string",
    "hosted": true,
    "fileUrl": "string",
    "name": "string",
    "parentId": "string"
  }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://services.leadconnectorhq.com/medias/upload-file', {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.LEADWAY_TOKEN}`,
      Version: '2021-07-28',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({"file": "string", "hosted": true, "fileUrl": "string", "name": "string", "parentId": "string"}),
  });
  const data = await response.json();
  ```

  ```python Python theme={null}
  import os, requests
  response = requests.request(
      'POST',
      'https://services.leadconnectorhq.com/medias/upload-file',
      headers={
          'Authorization': f"Bearer {os.environ['LEADWAY_TOKEN']}",
          'Version': '2021-07-28',
          'Content-Type': 'application/json',
      },
      json={"file": "string", "hosted": true, "fileUrl": "string", "name": "string", "parentId": "string"},
  )
  data = response.json()
  ```

  ```php PHP theme={null}
  <?php
  $ch = curl_init('https://services.leadconnectorhq.com/medias/upload-file');
  curl_setopt_array($ch, [
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_CUSTOMREQUEST => 'POST',
      CURLOPT_HTTPHEADER => [
          'Authorization: Bearer ' . getenv('LEADWAY_TOKEN'),
          'Version: 2021-07-28',
          'Content-Type: application/json',
      ],
      CURLOPT_POSTFIELDS => json_encode({'file': 'string', 'hosted': true, 'fileUrl': 'string', 'name': 'string', 'parentId': 'string'}),
  ]);
  $data = json_decode(curl_exec($ch), true);
  ```
</CodeGroup>
