# Get File

GET https://services.leadconnectorhq.com/files/d/{slug}

Get the file by slug.

## Authentication

Send `Authorization: Bearer <token>` using:

- **Sub-Account token: OAuth access token or Private Integration Token.** Scopes: `files.readonly`

## Parameters

### Header Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Version` | string | Yes | API Version |

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `slug` | string | Yes | Share-link slug identifying the file. |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "LeadConnector API",
    "version": "v3"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/files/d/{slug}": {
      "get": {
        "summary": "Get File",
        "operationId": "getFile",
        "description": "Get the file by slug.",
        "parameters": [
          {
            "name": "Version",
            "in": "header",
            "required": true,
            "description": "API Version",
            "schema": {
              "type": "string",
              "enum": [
                "v3"
              ]
            }
          },
          {
            "name": "slug",
            "required": true,
            "in": "path",
            "description": "Share-link slug identifying the file.",
            "schema": {
              "type": "string",
              "example": "4JpFVX1F57j8"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Returns a short-lived download URL and the file's metadata.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FileResponseDto"
                },
                "example": {
                  "allow_download": true,
                  "asset_id": "019ee07c-564f-785b-bc68-305b4fe30768",
                  "content_type": "application/pdf",
                  "filename": "🗃️ A Sample File - 11.pdf",
                  "size": 18810,
                  "url": "https://assets-registry.leadconnectorhq.com/5DP4iH6HLkQsiKESj6rh/4DkigiMRTkqxyAcHwGnO/document/YQPAlfnG8Hzptjg59Anv/019ee07c-564f-785b-bc68-305b4fe30768?Expires=1782375949&KeyName=assets-registry-key&Signature=tnFXYal8xDNonieCM6i4HngcUEM="
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid access token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FileErrorDto"
                },
                "example": {
                  "error": "Authentication required. Please provide a valid token."
                }
              }
            }
          },
          "403": {
            "description": "The token is not authorized to access this file.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FileErrorDto"
                },
                "example": {
                  "error": "You do not have access to this resource."
                }
              }
            }
          },
          "404": {
            "description": "No file exists for this link.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FileErrorDto"
                },
                "example": {
                  "error": "not found"
                }
              }
            }
          },
          "410": {
            "description": "This link has expired or is no longer available.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FileErrorDto"
                },
                "example": {
                  "error": "This link has expired"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearer": [
              "files.readonly"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Access token authorizing the request.",
        "type": "http"
      }
    },
    "schemas": {
      "FileResponseDto": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "description": "Short-lived, signed URL to download the file.",
            "example": "https://assets-registry.leadconnectorhq.com/5DP4iH6HLkQsiKESj6rh/4DkigiMRTkqxyAcHwGnO/document/YQPAlfnG8Hzptjg59Anv/019ee07c-564f-785b-bc68-305b4fe30768?Expires=1782375949&KeyName=assets-registry-key&Signature=tnFXYal8xDNonieCM6i4HngcUEM="
          },
          "asset_id": {
            "type": "string",
            "description": "Identifier of the file.",
            "example": "019ee07c-564f-785b-bc68-305b4fe30768"
          },
          "content_type": {
            "type": "string",
            "description": "MIME type of the file.",
            "example": "application/pdf"
          },
          "filename": {
            "type": "string",
            "description": "Original filename.",
            "example": "🗃️ A Sample File - 11.pdf"
          },
          "size": {
            "type": "integer",
            "format": "int64",
            "description": "File size in bytes.",
            "example": 18810
          },
          "allow_download": {
            "type": "boolean",
            "description": "Whether the file may be downloaded.",
            "example": true
          }
        },
        "required": [
          "url",
          "asset_id",
          "content_type",
          "filename",
          "size",
          "allow_download"
        ],
        "title": "FileResponseDto"
      },
      "FileErrorDto": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "description": "Human-readable error message.",
            "example": "This link has expired"
          }
        },
        "title": "FileErrorDto"
      }
    }
  }
}
```

## Code Examples

**cURL**

```bash
curl -L -X GET 'https://services.leadconnectorhq.com/files/d/<slug>' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: v3'
```

**Node.js**

```javascript
const options = {
  method: 'GET',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: 'v3'
  }
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/files/d/<slug>', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/files/d/{slug}"

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "v3"
}

response = requests.get(url, headers=headers)
print(response.json())
```

**PHP**

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/files/d/<slug>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: v3',
  ],
]);

$response = curl_exec($curl);
curl_close($curl);
echo $response;
```

**Java**

```java
HttpResponse<String> response = Unirest
  .get("https://services.leadconnectorhq.com/files/d/<slug>")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "v3")
  .asString();
```

**Go**

```go
package main

import (
  "fmt"
  "net/http"
  "io"
)

func main() {
  url := "https://services.leadconnectorhq.com/files/d/<slug>"
  req, _ := http.NewRequest("GET", url, nil)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "v3")

  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)
  fmt.Println(string(body))
}
```

**Ruby**

```ruby
require 'uri'
require 'net/http'

url = URI("https://services.leadconnectorhq.com/files/d/<slug>")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "v3"

response = http.request(request)
puts response.read_body
```

**PowerShell**

```powershell
$headers = @{
  "Authorization" = "Bearer <TOKEN>"
  "Version" = "v3"
}

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/files/d/<slug>' -Method 'GET' -Headers $headers
$response | ConvertTo-Json
```
