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

# Export Results

Generate and download PDF reports of completed KYC validation results. Reports include all scan results, matches, and metadata from the original screening.

## Endpoint

```
GET /exports/{jobId}
```

## Authentication

Requires `kyc:export` permission. Include your Bearer token in the Authorization header.

## Path Parameters

<ParamFields>
  <ParamField path="jobId" type="string" required description="The job/request ID from the KYC submission" />
</ParamFields>

## Description

This endpoint generates a PDF report for a completed KYC check and returns a presigned URL for downloading the report. The PDF includes:

* Entity information checked
* Lists scanned
* Match results (if any)
* Confidence scores
* Timestamps
* Processing metadata

## Request Example

```bash theme={null}
curl "https://stg.kyc.legaltalent.ai/exports/abc-123-def" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Accept: application/json"
```

## Response Format

### Success Response

```json theme={null}
{
  "request_id": "abc-123-def",
  "bucket": "kyc-exports-develop",
  "key": "exports/tenants/tenant123/abc-123-def.pdf",
  "presigned_url": "https://kyc-exports-develop.s3.amazonaws.com/exports/tenants/tenant123/abc-123-def.pdf?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIOSFODNN7EXAMPLE&X-Amz-Date=20241122T103000Z&X-Amz-Expires=3600&X-Amz-Signature=abc123def456"
}
```

### Response Fields

| Field           | Type   | Description                               |
| --------------- | ------ | ----------------------------------------- |
| `request_id`    | string | The job ID that was requested             |
| `bucket`        | string | S3 bucket name where PDF is stored        |
| `key`           | string | S3 object key (path)                      |
| `presigned_url` | string | Pre-signed URL valid for 1 hour (default) |

## Presigned URL Details

* **Validity**: 1 hour by default
* **Access**: Direct download via HTTPS
* **Format**: PDF document
* **Size**: Typically 50-500 KB depending on match count

## Usage Examples

### Download PDF with cURL

```bash theme={null}
# Get presigned URL
RESPONSE=$(curl -X GET "https://stg.kyc.legaltalent.ai/exports/abc-123-def" \
  -H "Authorization: Bearer YOUR_TOKEN")

# Extract presigned URL (using jq)
URL=$(echo $RESPONSE | jq -r '.presigned_url')

# Download the PDF
curl -o report.pdf "$URL"
```

### Python Example

```python theme={null}
import requests

job_id = "abc-123-def"
token = "YOUR_TOKEN"

# Get presigned URL
response = requests.get(
    f"https://stg.kyc.legaltalent.ai/exports/{job_id}",
    headers={"Authorization": f"Bearer {token}"}
)

if response.status_code == 200:
    data = response.json()
    presigned_url = data["presigned_url"]
    
    # Download PDF
    pdf_response = requests.get(presigned_url)
    with open("kyc_report.pdf", "wb") as f:
        f.write(pdf_response.content)
    
    print("PDF downloaded successfully")
else:
    print(f"Error: {response.json()}")
```

### JavaScript/Fetch Example

```javascript theme={null}
const jobId = "abc-123-def";
const token = "YOUR_TOKEN";

async function downloadReport() {
  // Get presigned URL
  const response = await fetch(
    `https://stg.kyc.legaltalent.ai/exports/${jobId}`,
    {
      method: "GET",
      headers: {
        "Authorization": `Bearer ${token}`,
        "Accept": "application/json"
      }
    }
  );

  const data = await response.json();
  
  if (response.ok) {
    // Download PDF in browser
    window.location.href = data.presigned_url;
    // Or download programmatically:
    // const pdfResponse = await fetch(data.presigned_url);
    // const blob = await pdfResponse.blob();
    // const url = window.URL.createObjectURL(blob);
    // const a = document.createElement('a');
    // a.href = url;
    // a.download = 'kyc_report.pdf';
    // a.click();
  } else {
    console.error("Error:", data.error);
  }
}
```

## Error Responses

### 400 Bad Request - Missing Job ID

```json theme={null}
{
  "error": "Missing request_id/job_id"
}
```

### 400 Bad Request - Missing Tenant ID

```json theme={null}
{
  "error": "Missing tenant_id"
}
```

### 404 Not Found

```json theme={null}
{
  "error": "Record not found"
}
```

This occurs when:

* The `jobId` is incorrect
* The record has been deleted
* The job never completed successfully
* The job belongs to a different tenant

### 500 Internal Server Error

```json theme={null}
{
  "error": "Internal error",
  "message": "Detailed error description"
}
```

## Status Codes

| Code | Description                                        |
| ---- | -------------------------------------------------- |
| 200  | Success - PDF generated and presigned URL returned |
| 400  | Bad Request - Invalid parameters                   |
| 401  | Unauthorized - Missing or invalid token            |
| 403  | Forbidden - Insufficient permissions               |
| 404  | Not Found - Job not found                          |
| 500  | Internal Server Error                              |

## PDF Report Contents

The generated PDF includes:

1. **Header Section**
   * Report generation timestamp
   * Job ID
   * Entity name checked

2. **Summary Section**
   * Total lists checked
   * Match status (Yes/No)
   * Overall risk level

3. **Entity Information**
   * Full name
   * Document ID (if provided)
   * Nationality (if provided)
   * Other identifiers

4. **Results by List**
   * List name
   * Match status
   * Match count
   * Confidence scores
   * Match details (entity names, programs)

5. **Metadata**
   * Processing time
   * Search type used
   * Timestamp

## Notes

* PDFs are generated on-demand when requested
* Reports are stored in S3 for 90 days (configurable)
* Presigned URLs expire after 1 hour
* Each tenant's reports are stored in separate S3 prefixes for data isolation
* Large reports (many matches) may take longer to generate

## Workflow

1. Perform KYC check via `POST /kyc`
2. Save the `job_id` from the response
3. Request export via `GET /exports/{jobId}`
4. Download PDF from the presigned URL
5. Presigned URL is valid for 1 hour
