{"schema_version":"1.0","publisher":"Primitive SDKs","canonical_url":"https://test.abhinandan.one/node-sdk-contract-module/node-sdk-contract-types","markdown_url":"https://test.abhinandan.one/node-sdk-contract-module/node-sdk-contract-types.md","article":{"id":"a1b37743-193c-4dfd-b701-539ad1a05771","article_slug":"node-sdk-contract-types","parent_article_slug":"node-sdk-contract-module","parent_article_title":"Building Webhook Payloads (Contract Module)","kind":"reference","published_at":"2026-08-11T18:54:59.233721+00:00","keywords":["@primitivedotdev/sdk/contract","EmailReceivedEventInput","ParsedInput","RawContentInline","RawContentDownloadOnly","buildEmailReceivedEvent"],"meta_description":"EmailReceivedEventInput, ParsedInput, and RawContentInline/DownloadOnly are the producer-side TypeScript types the contract module exports for building valid webhook fixtures.","og_image_url":null,"source_file_paths":[],"recording_id":null,"replayable":false,"task_name":"Primitive Contract Types Reference","category":"Node.js SDK","summary":null,"description":"Reference for the producer-side TypeScript types exported from @primitivedotdev/sdk/contract, used to build schema-valid email.received webhook payloads and test fixtures byte-for-byte.","content_kind":"repo_page","content_markdown":"## What the contract module is for\n\n`@primitivedotdev/sdk/contract` is a Node-only subpath of `@primitivedotdev/sdk` that exports the *producer-side* types and builder functions for the `email.received` webhook payload. Where the rest of the SDK (`@primitivedotdev/sdk/webhook`) is built for **consuming** an `EmailReceivedEvent` you received, `contract` is built for **constructing** one: writing test fixtures, building a mock webhook sender, or emitting payloads from a Primitive Function that fans events out to another system.\n\nFor the builder calls themselves (`buildEmailReceivedEvent`, `buildEventFromParsedData`), see [Building Webhook Payloads (Contract Module)](node-sdk-contract-module). For the consumer-side normalized object, see [Receiving Inbound Email](node-sdk-receiving-email).\n\n<Note>\n\n`contract` is one of the SDK's two Node-only subpaths (the other is `parser`). Use it in test fixtures, scripts, and server-side tooling.\n\n</Note>\n\n## Input types\n\nThese are the \"what you supply\" shapes. The builder functions in `@primitivedotdev/sdk/contract` take one of these and return an event that validates against the canonical webhook schema at `json-schema/email-received-event.schema.json`.\n\n| Type | Purpose |\n| --- | --- |\n| `EmailReceivedEventInput` | Top-level input to `buildEmailReceivedEvent`. |\n| `ParsedInput` | The `email.parsed` sub-object input, consumed by `buildEventFromParsedData`. |\n| `RawContentInline` | The `email.content.raw` variant where the raw MIME bytes are carried inline. |\n| `RawContentDownloadOnly` | The `email.content.raw` variant where the raw bytes are not inline and must be downloaded instead. |\n\n<Note>\n\nThis page indexes the *types*. For the builder call and the field values a typical fixture supplies, see [Building Webhook Payloads (Contract Module)](node-sdk-contract-module).\n\n</Note>\n\n### `RawContentInline` vs. `RawContentDownloadOnly`\n\nBoth describe `email.content.raw`, and a fixture picks exactly one of the two variants; mixing them produces a payload that fails schema validation the same way a malformed real payload would. The split mirrors the real API's behavior: a small message ships its raw MIME inline, and a larger one ships a download URL instead. Fixtures that exercise your download-path code should use `RawContentDownloadOnly`; everything else should use `RawContentInline`.\n\n## Builder functions\n\nThe two builder functions consume the input types above and return a fully schema-valid event. Full parameter-by-parameter documentation, including which fields are required vs. defaulted, lives on [Building Webhook Payloads (Contract Module)](node-sdk-contract-module).\n\n| Function | Input type | Output |\n| --- | --- | --- |\n| `buildEmailReceivedEvent` | `EmailReceivedEventInput` | A complete `EmailReceivedEvent` |\n| `buildEventFromParsedData` | `ParsedInput` | A complete `EmailReceivedEvent`, built starting from parsed-body data rather than full event fields |\n\n## Related consumer-side types\n\nThese are not exported from `contract`; they're the types you get back when *receiving* mail, documented on their owning pages. Listed here only so you don't confuse a producer-side input type with its consumer-side counterpart of a similar name.\n\n| Type | Where it's documented | Relationship to this page |\n| --- | --- | --- |\n| `EmailReceivedEvent` | [Receiving Inbound Email](node-sdk-receiving-email) | The output of both builder functions above, and the type validated by `validateEmailReceivedEvent` |\n| `ReceivedEmail` | [Receiving Inbound Email](node-sdk-receiving-email) | The normalized shape `primitive.receive(...)` returns; built from an `EmailReceivedEvent`, not from a contract input type |\n| `WebhookAttachment` | [Parsing Raw Email (.eml)](node-sdk-parsing-email) | The attachment shape carried on `EmailReceivedEvent.email.parsed.attachments` |\n\n## Next steps\n\n<CardGroup cols={2}>\n\n<Card title=\"Building Webhook Payloads (Contract Module)\" href=\"node-sdk-contract-module\">\n\nFull builder-function reference: field-by-field defaults and end-to-end fixture examples.\n\n</Card>\n\n<Card title=\"Receiving Inbound Email\" href=\"node-sdk-receiving-email\">\n\nThe consumer-side ReceivedEmail shape and the normalizer that produces it.\n\n</Card>\n\n<Card title=\"Webhook Signature Verification\" href=\"node-sdk-webhook-signing\">\n\nVerify the Primitive-Signature HMAC header so a hand-built fixture round-trips through your own handler.\n\n</Card>\n\n<Card title=\"Node.js SDK Errors\" href=\"node-sdk-errors\">\n\nWebhookValidationError and WebhookPayloadError codes raised when a hand-built fixture doesn't validate.\n\n</Card>\n\n</CardGroup>","canonical_base_url":"https://test.abhinandan.one","seo_indexing_enabled":true,"last_modified":"2026-08-21T18:22:43.359885+00:00","video_url":null,"voiceover_url":null,"tools_used":[],"demonstrated_by":[],"steps":[],"related_links":[],"intro":null,"prerequisites":[],"verification":[],"troubleshooting":[],"suggest_edit_url":null,"raise_issue_url":"https://github.com/abhi-browzer/primitive-sdks/issues/new?title=Docs+feedback%3A+Primitive+Contract+Types+Reference&body=Page%3A+https%3A%2F%2Ftest.abhinandan.one%2Fnode-sdk-contract-types","page_feedback_enabled":true,"verified_ref":null,"verified_at":"2026-08-11T18:38:45.205849+00:00"}}