{"_id":"@anymail/sdk","name":"@anymail/sdk","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@anymail/sdk","version":"0.1.0","description":"Official TypeScript/JavaScript client for the AnyMail Developer API (/api/v1). Generated from the server's own OpenAPI spec - see ../README.md.","license":"UNLICENSED","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"scripts":{"generate-types":"openapi-typescript ../openapi.json -o src/generated/types.ts","build":"tsc -p tsconfig.json","typecheck":"tsc --noEmit","test":"vitest run"},"dependencies":{"openapi-fetch":"^0.17.0"},"devDependencies":{"msw":"^2.15.0","openapi-typescript":"^7.13.0","typescript":"^5.5.3","vitest":"^4.1.11"},"_id":"@anymail/sdk@0.1.0","gitHead":"03388ff50f44270d9d7ec13dfba812d9465f729d","_nodeVersion":"20.20.2","_npmVersion":"10.8.2","dist":{"integrity":"sha512-l3ro2DZgwAoAy0lxvt/d1OLdPv35SYAnpi2l9ayIGnvmO6pPcN7Uhd2Gsn6iNm4D15ruQQqj+BBcUHSH5dBnGw==","shasum":"b3cf60eaefd5fa205309b027a2512023eb3b908d","tarball":"https://registry.npmjs.org/@anymail/sdk/-/sdk-0.1.0.tgz","fileCount":10,"unpackedSize":59706,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIEelMQTOPehzK0IynoYOf+pw4qC48Yy47Uw8ANFtAsS3AiEA8fE0D/D2xQiUyugfQxoH48sAQvBmj8dP1r2D/kGvFuc="}]},"_npmUser":{"name":"michal.platosz","email":"platosz.michal@gmail.com"},"directories":{},"maintainers":[{"name":"michal.platosz","email":"platosz.michal@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sdk_0.1.0_1787264894478_0.24393550364003747"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-20T22:28:14.311Z","0.1.0":"2026-08-20T22:28:14.631Z","modified":"2026-08-20T22:28:14.868Z"},"maintainers":[{"name":"michal.platosz","email":"platosz.michal@gmail.com"}],"description":"Official TypeScript/JavaScript client for the AnyMail Developer API (/api/v1). Generated from the server's own OpenAPI spec - see ../README.md.","license":"UNLICENSED","readme":"# @anymail/sdk (TypeScript/JavaScript)\n\nOfficial TypeScript/JavaScript client for the [AnyMail](https://anymail.tech) Developer API\n(`/api/v1`).\n\n`src/generated/types.ts` is generated fresh from `../openapi.json` by\n[openapi-typescript](https://openapi-ts.dev) - see `../scripts/generate-spec.ts` and\n`../README.md`. `src/client.ts`, `src/webhooks.ts`, and `src/index.ts` are the hand-written files\nin this package.\n\n## Install\n\n```bash\nnpm install @anymail/sdk\n```\n\n### Self-hosted alternative\n\nIf you'd rather install straight from an AnyMail deployment instead of npm (or npm publishing\nisn't turned on for this deployment yet - see `../README.md` \"Publishing\"), npm can install\ndirectly from a tarball URL - no filename-detection trick needed here, unlike pip:\n\n```bash\nnpm install https://anymail.tech/api/sdk-artifacts/typescript\n```\n\n## Usage\n\n```ts\nimport { AnyMailClient, unwrapOrThrow } from '@anymail/sdk';\n\nconst client = new AnyMailClient({ apiKey: 'am_...' }); // baseUrl defaults to https://anymail.tech/api/v1\n\n// Full type inference for every endpoint via client.api (openapi-fetch), no per-endpoint code:\nconst { data, error } = await client.api.GET('/mail-servers/{id}', { params: { path: { id: 'ms_...' } } });\n\n// Or throw-on-error, matching AnyMail's own {code, message} error contract:\nconst { user } = unwrapOrThrow(await client.api.GET('/me'));\n\nconst { message } = unwrapOrThrow(\n  await client.api.POST('/inboxes/{id}/messages', {\n    params: { path: { id: 'inb_...' } },\n    body: { to: 'someone@example.com', subject: 'Hi', body: 'Hello!' }\n  })\n);\n```\n\n`client.api` is a real [openapi-fetch](https://openapi-ts.dev/openapi-fetch/) client typed\nagainst the generated `paths` - every Developer API endpoint (including ones added after this\nREADME was written) is reachable through it with full type inference. `unwrapOrThrow` is a small,\ngeneric helper (not tied to any one endpoint) that turns a `{data, error}` result into `data`, or\nthrows `AnyMailApiError` carrying the server's `status`/`code`/`message`/`details`.\n\n## Webhook signature verification\n\n```ts\nimport { verifyWebhookSignature } from '@anymail/sdk';\n\nif (!verifyWebhookSignature(rawBody, req.headers['x-anymail-signature'], webhookSecret)) {\n  return res.status(400).end();\n}\n```\n\n`rawBody` must be the exact string of the received request body, read before any JSON parsing -\nsee the function's docstring. Node-only (uses `node:crypto`), which is fine since webhook\nverification always runs on the receiving server, never in a browser. This helper is unrelated to\n`client.api` and works even if you're not otherwise using this SDK to call the API.\n\n## Regenerating\n\nSee `../README.md` \"Regenerating locally\".\n","readmeFilename":"README.md","_rev":"1-f5ef14503a0f4c92d794e3a3cbafdd57"}