# AWS SQS Event

> AWS SQS event with message records, attributes, and source ARN.

- Name: `aws-sqs-event`
- Categories: aws
- Detail page: https://open-types.dev/types/aws-sqs-event

## Install

```bash
# Types only
npx shadcn add @open-types/aws-sqs-event

# Types + Zod v4 validators
npx shadcn add @open-types/aws-sqs-event-zod

# Types + real-world examples
npx shadcn add @open-types/aws-sqs-event-examples
```

## Types

```typescript
export interface AWSSQSMessageAttribute {
  stringValue?: string;
  dataType: string;
}

export interface AWSSQSRecord {
  messageId: string;
  receiptHandle: string;
  body: string;
  attributes: Record<string, string>;
  messageAttributes: Record<string, AWSSQSMessageAttribute>;
  md5OfBody: string;
  eventSource: string;
  eventSourceARN: string;
  awsRegion: string;
}

export interface AWSSQSEvent {
  Records: AWSSQSRecord[];
}
```

## Zod validator

```typescript
import * as z from "zod";
import type {
  AWSSQSMessageAttribute,
  AWSSQSRecord,
  AWSSQSEvent,
} from "../types/aws-sqs-event";

export const awsSqsMessageAttributeSchema = z.object({
  stringValue: z.string().optional(),
  dataType: z.string(),
}) satisfies z.ZodType<AWSSQSMessageAttribute>;

export const awsSqsRecordSchema = z.object({
  messageId: z.string(),
  receiptHandle: z.string(),
  body: z.string(),
  attributes: z.record(z.string(), z.string()),
  messageAttributes: z.record(z.string(), awsSqsMessageAttributeSchema),
  md5OfBody: z.string(),
  eventSource: z.string(),
  eventSourceARN: z.string(),
  awsRegion: z.string(),
}) satisfies z.ZodType<AWSSQSRecord>;

export const awsSqsEventSchema = z.object({
  Records: z.array(awsSqsRecordSchema),
}) satisfies z.ZodType<AWSSQSEvent>;

export type {
  AWSSQSMessageAttribute,
  AWSSQSRecord,
  AWSSQSEvent,
} from "../types/aws-sqs-event";
```

## Examples

```typescript
// Source: https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html#example-standard-queue-message-event
// Captured: 2026-05
import type {
  AWSSQSMessageAttribute,
  AWSSQSRecord,
  AWSSQSEvent,
} from "../types/aws-sqs-event";

const stringAttr = {
  stringValue: "order.created",
  dataType: "String",
} as const satisfies AWSSQSMessageAttribute;

export const awsSqsMessageAttributeExamples = {
  string: stringAttr,
  number: {
    stringValue: "42",
    dataType: "Number",
  } satisfies AWSSQSMessageAttribute,
  binary: { dataType: "Binary" } satisfies AWSSQSMessageAttribute,
} as const;

const record = {
  messageId: "6f7e1df9-8b8d-4f0f-88a9-b4cf9eb7f5b8",
  receiptHandle: "AQEBJQxO6qexampleReceiptHandle==",
  body: '{"orderId":"ord_123","status":"created"}',
  attributes: {
    ApproximateReceiveCount: "1",
    SentTimestamp: "1776105100000",
    SenderId: "AIDAEXAMPLE123456789",
  },
  messageAttributes: { eventType: stringAttr },
  md5OfBody: "098f6bcd4621d373cade4e832627b4f6",
  eventSource: "aws:sqs",
  eventSourceARN: "arn:aws:sqs:us-east-1:123456789012:orders-queue",
  awsRegion: "us-east-1",
} as const satisfies AWSSQSRecord;

export const awsSqsRecordExamples = {
  standard: record,
  fifo: {
    ...record,
    messageId: "fifo-message-id-001",
    eventSourceARN: "arn:aws:sqs:us-east-1:123456789012:orders-queue.fifo",
    attributes: {
      ...record.attributes,
      MessageGroupId: "tenant-42",
      MessageDeduplicationId: "ord_123-2026-05-16",
    },
  } satisfies AWSSQSRecord,
  retry: {
    ...record,
    attributes: { ...record.attributes, ApproximateReceiveCount: "5" },
  } satisfies AWSSQSRecord,
  noMessageAttributes: { ...record, messageAttributes: {} } satisfies AWSSQSRecord,
} as const;

export const awsSqsEventExamples = {
  single: { Records: [record] } satisfies AWSSQSEvent,
  batch: {
    Records: [
      record,
      { ...record, messageId: "b3e1d2f4-2a3b-4c5d-6e7f-8a9b0c1d2e3f" },
      { ...record, messageId: "c4e2d3f5-3b4c-5d6e-7f8a-9b0c1d2e3f4a" },
    ],
  } satisfies AWSSQSEvent,
} as const;
```
