Skip to content
OpenSmartRoute
Skillv1.0.0

persona-sdk-patterns

Production Persona API client wrapper with retry, pagination, typed responses. Use when working with Persona identity verification. Trigger with phrases like "persona sdk-patterns", "persona sdk-patte

by jeremylongshore(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from jeremylongshore/tons-of-skills-marketplace (skills/.curated/persona-sdk-patterns/SKILL.md). Install upstream with npx skills add jeremylongshore/tons-of-skills-marketplace --skill persona-sdk-patterns. Copyright stays with the author (MIT).

persona sdk patterns | sed 's/\b(.)/\u\1/g'

Overview

Singleton API client, typed verification results, pagination through inquiries, error classification.

Prerequisites

  • Completed persona-install-auth setup
  • Valid Persona API key (sandbox or production)

Instructions

Step 1: Typed API Client Wrapper

import axios, { AxiosInstance, AxiosError } from 'axios';

interface PersonaConfig {
  apiKey: string;
  version?: string;
  baseURL?: string;
}

class PersonaClient {
  private http: AxiosInstance;

  constructor(config: PersonaConfig) {
    this.http = axios.create({
      baseURL: config.baseURL || 'https://withpersona.com/api/v1',
      headers: {
        'Authorization': `Bearer ${config.apiKey}`,
        'Persona-Version': config.version || '2023-01-05',
        'Content-Type': 'application/json',
      },
    });
  }

  async createInquiry(templateId: string, referenceId: string, fields?: Record<string, any>) {
    const { data } = await this.http.post('/inquiries', {
      data: { attributes: { 'inquiry-template-id': templateId, 'reference-id': referenceId, fields } },
    });
    return data.data;
  }

  async getInquiry(inquiryId: string) {
    const { data } = await this.http.get(`/inquiries/${inquiryId}`);
    return data.data;
  }

  async listInquiries(params: { referenceId?: string; status?: string; pageSize?: number } = {}) {
    const { data } = await this.http.get('/inquiries', {
      params: {
        'filter[reference-id]': params.referenceId,
        'filter[status]': params.status,
        'page[size]': params.pageSize || 25,
      },
    });
    return data.data;
  }

  async getVerification(verificationId: string) {
    const { data } = await this.http.get(`/verifications/${verificationId}`);
    return data.data;
  }
}

// Singleton
let _client: PersonaClient | null = null;
export function getPersonaClient(): PersonaClient {
  if (!_client) {
    _client = new PersonaClient({ apiKey: process.env.PERSONA_API_KEY! });
  }
  return _client;
}

Step 2: Error Classification

function classifyPersonaError(error: AxiosError): { retryable: boolean; message: string } {
  const status = error.response?.status;
  if (status === 429) return { retryable: true, message: 'Rate limited' };
  if (status && status >= 500) return { retryable: true, message: 'Server error' };
  if (status === 401) return { retryable: false, message: 'Invalid API key' };
  if (status === 422) return { retryable: false, message: 'Invalid request' };
  return { retryable: false, message: error.message };
}

Output

  • Typed Persona API client with inquiry and verification methods
  • Singleton pattern for reuse
  • Error classification for retry decisions
  • Paginated inquiry listing

Error Handling

Pattern Use Case Benefit
Singleton All API calls One client, consistent headers
Error classifier Retry decisions Only retry 429/5xx
Typed responses Data access Autocomplete, type safety

Resources

Next Steps

Apply in persona-core-workflow-a for real KYC flows.

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/jeremylongshore-tons-of-skills-marketplace-persona-sdk-patterns/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

jeremylongshore-tons-of-skills-marketplace-persona-sdk-patterns.ocm.jsonjson
{
  "ocm": "1",
  "id": "jeremylongshore-tons-of-skills-marketplace-persona-sdk-patterns",
  "kind": "skill",
  "name": "persona-sdk-patterns",
  "description": "Production Persona API client wrapper with retry, pagination, typed responses. Use when working with Persona identity verification. Trigger with phrases like \"persona sdk-patterns\", \"persona sdk-patterns\".",
  "publisher": "jeremylongshore",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "coding"
    ],
    "tags": [
      "skill-md",
      "saas",
      "persona",
      "identity",
      "kyc",
      "verification",
      "skills-sh"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Production Persona API client wrapper with retry, pagination, typed responses. Use when working with Persona identity verification. Trigger with phrases like \"persona sdk-patterns\", \"persona sdk-patterns\"."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "skills.sh",
      "repository": "https://github.com/jeremylongshore/tons-of-skills-marketplace",
      "path": "skills/.curated/persona-sdk-patterns/SKILL.md",
      "ref": "HEAD",
      "url": "https://github.com/jeremylongshore/tons-of-skills-marketplace/blob/HEAD/skills/.curated/persona-sdk-patterns/SKILL.md",
      "key": "jeremylongshore/tons-of-skills-marketplace/skills/.curated/persona-sdk-patterns/SKILL.md"
    },
    "compatibility": "Designed for Claude Code",
    "allowed_tools": [
      "Read,",
      "Write,",
      "Edit"
    ],
    "license": "MIT"
  },
  "instructions": "# persona sdk patterns | sed 's/\\b\\(.\\)/\\u\\1/g'\n\n## Overview\n\nSingleton API client, typed verification results, pagination through inquiries, error classification.\n\n## Prerequisites\n\n- Completed `persona-install-auth` setup\n- Valid Persona API key (sandbox or production)\n\n## Instructions\n\n### Step 1: Typed API Client Wrapper\n\n```typescript\nimport axios, { AxiosInstance, AxiosError } from 'axios';\n\ninterface PersonaConfig {\n  apiKey: string;\n  version?: string;\n  baseURL?: string;\n}\n\nclass PersonaClient {\n  private http: AxiosInstance;\n\n  constructor(config: PersonaConfig) {\n    this.http = axi",
  "cost": {
    "context_tokens": 820
  }
}

Fetch it by URL: GET /api/v1/registry/jeremylongshore-tons-of-skills-marketplace-persona-sdk-patterns/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.