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

# API reference

> Read analysis results and control the SDK with faceAge.API.

After calling `faceAge.render()`, use `faceAge.API` to read results and control the SDK.

## Results

### getAdvisorData

Read the analysis results and quiz answers:

```js theme={null}
faceAge.API.getAdvisorData((data) => {
  console.log(data.analysis);         // skin age, damage %, detected problems
  console.log(data.activeSelections); // quiz answers
});
```

### getActiveSelections

Read the quiz answers:

```js theme={null}
faceAge.API.getActiveSelections((data) => {
  console.log(data); // { email, skinType, ... }
});
```

### getImage

Read the submitted image:

```js theme={null}
const image = faceAge.API.getImage();
```

### getRoutineGroup

Read the available routine groups:

```js theme={null}
const groups = faceAge.API.getRoutineGroup();
```

## Products

### setCustomProducts

Push your own product catalog into the SDK. Products are matched to detected skin problems automatically.

```js theme={null}
faceAge.API.setCustomProducts([
  {
    id: 1,
    url: 'https://yourstore.com/product',
    image: 'https://yourstore.com/product.png',
    title: 'Skin Moisturizer',
    description: 'Vitamin C · 30ml',                   // optional
    price: 40,
    offerPrice: 18.99,                                  // optional sale price
    problems: ['acne', 'wrinkles'],                     // optional: target problems
    routineGroups: { morning: ['cleanser', 'serum'] },  // optional
    variables: {                                        // optional: size/variant picker
      size: {
        title: 'Size',
        option: [
          { label: '10 cc', value: '10', price: 40, offerPrice: 18.99 },
          { label: '25 cc', value: '25', price: 52 },
          { label: '35 cc', value: '35' },
        ],
      },
    },
  },
]);
```

## History

### setHistoryData

Restore history from your backend. Requires the `history: true` option.

```js theme={null}
faceAge.API.setHistoryData({
  analysis: {
    analyze_ref_token: 'analyze_ref_abc123',
    skinAge: 28,
    damagePercentage: 12.4,
    problems: [],
  },
  activeSelections: {
    email: 'user@example.com',
    skinType: 'combination',
  },
  meta: {
    ts: Date.now(),
    image: 'https://example.com/scan.jpg',
    // Optional; values can use either 0..1 or 0..100.
    quality: {
      lightingScore: 0.92, // higher is better
      brightness: 0.53,    // used to detect lighting mismatch
      sharpnessScore: 0.88,
      blur: 0.08,          // lower is better
      noise: 0.10,         // lower is better
      confidence: 0.94,
    },
  },
});
```

When several history items are available, opening an analysis shows a **Compare** tab to compare it with any older scan. Shared metrics are normalized before comparison. Changes inside a 3-point noise band are treated as stable; the optional `meta.quality` values widen that band, or mark very low-confidence comparisons as insufficient data.

### removeHistoryItem

Remove a history entry by its reference token. Pass `null` to clear all local history.

```js theme={null}
faceAge.API.removeHistoryItem('analyze_ref_abc123').then((removed) => {
  console.log('Removed:', removed);
});
```

## Routine tab content

### setComments

Fill the customer review carousel in the routine tab.

```js theme={null}
faceAge.API.setComments([
  {
    name: 'Jane Doe',
    comment: 'My skin feels amazing after just two weeks!', // also accepts: text, body
    image: 'https://example.com/avatar.jpg',               // optional; also: avatar, photo
    job_position: 'Verified Buyer',                        // optional; also: jobPosition, position, company
  },
]);
```

Each item needs `name` and one of `comment`, `text` or `body`. Comments longer than 280 characters are truncated with a "read more" toggle. Returns `true` on success, `false` on error.

### setShorts

Fill the short video/image carousel in the routine tab.

```js theme={null}
faceAge.API.setShorts([
  {
    coverImage: 'https://example.com/thumb.jpg', // also: cover_image, cover, image, thumbnail, poster
    videoUrl: 'https://example.com/clip.mp4',    // optional; also: video_url, video, src
    link: 'https://example.com/product',         // optional; also: url, href
    overlayText: 'Morning Routine',              // optional; also: overlay_text, title, text, caption, overlay
  },
]);
```

Each item needs `coverImage` or `videoUrl`. `javascript:`, `data:` and `vbscript:` URLs are rejected. Returns `true` on success, `false` on error.

### setSort

Set the order of the tabs on the analysis result page: `scan`, `routine` and `recommendations`. Tabs you don't list keep their default position after the ones you do.

```js theme={null}
// Show the routine tab first, then recommendations, then scan
faceAge.API.setSort(['routine', 'recommendations', 'scan']);
```

| Tab | Accepted aliases |
| - | - |
| `scan` | `scan`, `scan_info`, `scaninfo`, `skin_report`, `skinreport` |
| `routine` | `routine`, `routines` |
| `recommendations` | `recommendations`, `recommendation`, `products`, `product` |

If the result page is already open, the tabs are re-ordered immediately. Returns `true` on success, `false` on error.

## Reports and integrations

### getReportPdf

Generate a PDF report. Requires PDF access on your Face Age plan.

```js theme={null}
faceAge.API.getReportPdf()
  .then((report) => console.log('Report:', report))
  .catch((err) => console.error('Failed:', err));
```

### submitSdkIntegration

Send the full analysis payload — skin results, products, quiz data and brand metadata — to the SDK-call integration endpoint. Without an email argument, Face Age uses `email` or `clientEmail` from the quiz answers.

```js theme={null}
// Basic
faceAge.API.submitSdkIntegration('user@example.com').then((res) => {
  console.log('Submitted:', res);
});

// With extra metadata
faceAge.API.submitSdkIntegration('user@example.com', {
  name: 'Jane Doe',
  skinType: 'dry',
  skinConcern: ['fineWrinkles', 'dryness'],
});
```

Quiz data is normalized to `[{ question, answer }]` before submission.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.