Luna SaludAPI ReferenceLuna Salud

Download a completed patient form as PDF

GET/patient-form/pdf

Returns the PDF of one completed form, base64-encoded in content_base64: the same file stored in the patient's Forms folder when the form was completed, signatures included. generated_at is when the PDF was made; if updated_at on GET /patient-form is later, the PDF may not show the latest edit. Answers 404 when the form has no stored PDF, in which case read the answers with GET /patient-form. PDFs over 10 MB are not returned. Scoped to your organization.

Code samples

Node.js

const fetch = require('node-fetch');

async function callApi() {
  const apiKey = 'YOUR_API_KEY';
  const id = 'your-id';

const queryString = new URLSearchParams({
    id: id
  }).toString();

  const url = `https://account.lunahealth.app/api/patient-form/pdf` + (queryString ? `?${queryString}` : '');
  try {
    const response = await fetch(url, {
      method: 'GET',
      headers: {
        'Authorization': `Bearer ${apiKey}`,
        'Content-Type': 'application/json'
      }
    });
    
    if (!response.ok) {
      throw new Error(`API error: ${response.status}`);
    }
    
    const data = await response.json();
    console.log(data);
    return data;
  } catch (error) {
    console.error('Error calling API:', error);
    throw error;
  }
}

callApi();

Python

import requests

def call_api():
    api_key = 'YOUR_API_KEY'
    
    url = 'https://account.lunahealth.app/api/patient-form/pdf'
    
    headers = {
        'Authorization': f'Bearer {api_key}',
        'Content-Type': 'application/json'
    }
    
    params = {
    'id': 'your-id'
    }
    
    try:
        response = requests.get(
            url,
            headers=headers,
            params=params
        )
        response.raise_for_status()
        
        data = response.json()
        print(data)
        return data
    except requests.exceptions.RequestException as e:
        print(f'Error calling API: {e}')
        raise

call_api()

Parameters

NameInTypeRequiredDescription
idquerystringYes—

Responses

StatusDescription
200Successful response
400Invalid input data
401Authorization not provided
403Insufficient access
404Not found
500Internal server error

200 — Successful response

Response fields

NameTypeRequiredDescription
idstringYes—
patient_idstringYes—
file_namestringYes—
content_typestringYes—
size_bytesintegerYes—
content_base64stringYes—
generated_atstringYes—

Example response

{
  "id": "string",
  "patient_id": "string",
  "file_name": "string",
  "content_type": "string",
  "size_bytes": 0,
  "content_base64": "string",
  "generated_at": "string"
}

400 — Invalid input data

Response fields

NameTypeRequiredDescription
messagestringYesThe error message
codestringYesThe error code
issuesarray<object>NoAn array of issues that were responsible for the error

Example response

{
  "code": "BAD_REQUEST",
  "message": "Invalid input data",
  "issues": []
}

401 — Authorization not provided

Response fields

NameTypeRequiredDescription
messagestringYesThe error message
codestringYesThe error code
issuesarray<object>NoAn array of issues that were responsible for the error

Example response

{
  "code": "UNAUTHORIZED",
  "message": "Authorization not provided",
  "issues": []
}

403 — Insufficient access

Response fields

NameTypeRequiredDescription
messagestringYesThe error message
codestringYesThe error code
issuesarray<object>NoAn array of issues that were responsible for the error

Example response

{
  "code": "FORBIDDEN",
  "message": "Insufficient access",
  "issues": []
}

404 — Not found

Response fields

NameTypeRequiredDescription
messagestringYesThe error message
codestringYesThe error code
issuesarray<object>NoAn array of issues that were responsible for the error

Example response

{
  "code": "NOT_FOUND",
  "message": "Not found",
  "issues": []
}

500 — Internal server error

Response fields

NameTypeRequiredDescription
messagestringYesThe error message
codestringYesThe error code
issuesarray<object>NoAn array of issues that were responsible for the error

Example response

{
  "code": "INTERNAL_SERVER_ERROR",
  "message": "Internal server error",
  "issues": []
}