Search Plus UI Blocks

Find a block, a category or a site

API guide with pinned codeapi-guide-code-aside

Use in Plus UI
npx shadcn@latest add https://blocks.plusui.com/r/api-guide-code-aside.json

Guides · 4 variants

← → to step through · + on a thumbnail to compare side by side (up to 3)

/preview/api-guide-code-aside
Open ↗

Default content

{
  "eyebrow": "Getting started",
  "title": "Authentication",
  "lead": "Every request carries a secret key in the `Authorization` header. Test keys buy free labels that never ship; live keys buy real postage from your balance.",
  "body": [
    {
      "type": "heading",
      "level": 2,
      "text": "API keys"
    },
    {
      "type": "paragraph",
      "text": "Create keys in the dashboard under Developers → API keys. Each key starts with a prefix that tells you what it can do: `sc_test_` for the sandbox and `sc_live_` for real labels."
    },
    {
      "type": "list",
      "ordered": false,
      "items": [
        "`sc_test_…` — free, labels are watermarked and never handed to a carrier",
        "`sc_live_…` — charges your balance for every label you create",
        "`sc_rk_…` — restricted keys, limited to the scopes you choose"
      ]
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Sending the key"
    },
    {
      "type": "paragraph",
      "text": "Send the key as a bearer token. Requests without a key, or with a revoked one, return `401 unauthorized`."
    },
    {
      "type": "callout",
      "tone": "warning",
      "title": "Keep live keys on the server",
      "text": "Never put a live key in a browser or a mobile app. Anyone who reads it can buy postage on your account."
    },
    {
      "type": "heading",
      "level": 2,
      "text": "Rotating keys"
    },
    {
      "type": "paragraph",
      "text": "Roll a key from the dashboard and the old one keeps working for 24 hours, so you can deploy the new one without downtime."
    }
  ],
  "aside": {
    "title": "Authenticated request",
    "samples": [
      {
        "label": "curl",
        "language": "shell",
        "code": "$ curl https://api.stampcove.com/v1/labels \\\n    -H \"Authorization: Bearer $STAMPCOVE_KEY\""
      },
      {
        "label": "Node",
        "language": "ts",
        "code": "import Stampcove from \"stampcove\"\n\nconst stampcove = new Stampcove(process.env.STAMPCOVE_KEY)\nconst labels = await stampcove.labels.list({ limit: 3 })"
      },
      {
        "label": "Python",
        "language": "python",
        "code": "import os, stampcove\n\nclient = stampcove.Client(os.environ[\"STAMPCOVE_KEY\"])\nlabels = client.labels.list(limit=3)"
      }
    ],
    "response": {
      "status": 401,
      "text": "Unauthorized",
      "body": "{\n  \"error\": {\n    \"type\": \"unauthorized\",\n    \"message\": \"No API key provided. Send it as a Bearer token.\"\n  }\n}"
    },
    "note": "Test and live keys hit the same base URL; the prefix decides the mode."
  },
  "previous": {
    "label": "Introduction",
    "href": "#"
  },
  "next": {
    "label": "Errors",
    "href": "#"
  },
  "labels": {
    "copy": "Copy",
    "copied": "Copied",
    "response": "Response",
    "previous": "Previous",
    "next": "Next"
  }
}