---
title: "Primitive Contract Types Reference"
canonical: "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"
publisher: "Primitive SDKs"
kind: "reference"
content_type: "reference"
category: "Node.js SDK"
parent: "node-sdk-contract-module"
description: "EmailReceivedEventInput, ParsedInput, and RawContentInline/DownloadOnly are the producer-side TypeScript types the contract module exports for building valid webhook fixtures."
keywords: ["@primitivedotdev/sdk/contract", "EmailReceivedEventInput", "ParsedInput", "RawContentInline", "RawContentDownloadOnly", "buildEmailReceivedEvent"]
last_modified: "2026-08-11T18:55:00.451232+00:00"
published_at: "2026-08-11T18:54:59.233721+00:00"
sections:
  - {anchor: "what-the-contract-module-is-for", title: "What the contract module is for"}
  - {anchor: "input-types", title: "Input types"}
  - {anchor: "rawcontentinline-vs-rawcontentdownloadonly", title: "`RawContentInline` vs. `RawContentDownloadOnly`"}
  - {anchor: "builder-functions", title: "Builder functions"}
  - {anchor: "related-consumer-side-types", title: "Related consumer-side types"}
  - {anchor: "next-steps", title: "Next steps"}
---

> Documentation index: https://test.abhinandan.one/llms.txt

# Primitive Contract Types Reference

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.

## What the contract module is for

`@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.

For the builder calls themselves (`buildEmailReceivedEvent`, `buildEventFromParsedData`), see [Building Webhook Payloads (Contract Module)](https://test.abhinandan.one/node-sdk-contract-module.md). For the consumer-side normalized object, see [Receiving Inbound Email](https://test.abhinandan.one/node-sdk-receiving-email.md).

> **Note:** `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.

## Input types

These 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`.

| Type | Purpose |
| --- | --- |
| `EmailReceivedEventInput` | Top-level input to `buildEmailReceivedEvent`. |
| `ParsedInput` | The `email.parsed` sub-object input, consumed by `buildEventFromParsedData`. |
| `RawContentInline` | The `email.content.raw` variant where the raw MIME bytes are carried inline. |
| `RawContentDownloadOnly` | The `email.content.raw` variant where the raw bytes are not inline and must be downloaded instead. |

> **Note:** This page indexes the *types*. For the builder call and the field values a typical fixture supplies, see [Building Webhook Payloads (Contract Module)](https://test.abhinandan.one/node-sdk-contract-module.md).

### `RawContentInline` vs. `RawContentDownloadOnly`

Both 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`.

## Builder functions

The 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)](https://test.abhinandan.one/node-sdk-contract-module.md).

| Function | Input type | Output |
| --- | --- | --- |
| `buildEmailReceivedEvent` | `EmailReceivedEventInput` | A complete `EmailReceivedEvent` |
| `buildEventFromParsedData` | `ParsedInput` | A complete `EmailReceivedEvent`, built starting from parsed-body data rather than full event fields |

## Related consumer-side types

These 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.

| Type | Where it's documented | Relationship to this page |
| --- | --- | --- |
| `EmailReceivedEvent` | [Receiving Inbound Email](https://test.abhinandan.one/node-sdk-receiving-email.md) | The output of both builder functions above, and the type validated by `validateEmailReceivedEvent` |
| `ReceivedEmail` | [Receiving Inbound Email](https://test.abhinandan.one/node-sdk-receiving-email.md) | The normalized shape `primitive.receive(...)` returns; built from an `EmailReceivedEvent`, not from a contract input type |
| `WebhookAttachment` | [Parsing Raw Email (.eml)](https://test.abhinandan.one/node-sdk-parsing-email.md) | The attachment shape carried on `EmailReceivedEvent.email.parsed.attachments` |
