Skip to content

Commit 6f4849e

Browse files
committed
Add AGENTS.md for AI coding assistants
Provides structured context for AI agents (Cursor, Claude Code, Codex) working with the Courier Java SDK: core send pattern with builder API, key rules (routing defaults, profile merge vs replace, idempotency, bulk flow), concept definitions, and links to full docs/MCP/skills.
1 parent 8efc854 commit 6f4849e

1 file changed

Lines changed: 60 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Courier Java SDK
2+
3+
Courier is a notifications API for sending messages across email, SMS, push, in-app inbox, Slack, and WhatsApp from a single API call.
4+
5+
## Setup
6+
7+
```java
8+
import com.courier.client.CourierClient;
9+
import com.courier.client.okhttp.CourierOkHttpClient;
10+
11+
CourierClient client = CourierOkHttpClient.fromEnv(); // reads COURIER_API_KEY from env
12+
```
13+
14+
## Core pattern
15+
16+
```java
17+
import com.courier.core.JsonValue;
18+
import com.courier.models.UserRecipient;
19+
import com.courier.models.send.SendMessageParams;
20+
import com.courier.models.send.SendMessageResponse;
21+
22+
SendMessageParams params = SendMessageParams.builder()
23+
.message(SendMessageParams.Message.builder()
24+
.to(UserRecipient.builder().userId("user_123").build())
25+
.template("TEMPLATE_ID")
26+
.data(SendMessageParams.Message.Data.builder()
27+
.putAdditionalProperty("order_id", JsonValue.from("456"))
28+
.build())
29+
.build())
30+
.build();
31+
32+
SendMessageResponse response = client.send().message(params);
33+
System.out.println(response.requestId());
34+
```
35+
36+
## Key rules
37+
38+
- Use `routing.method: "single"` (fallback chain) unless the user explicitly asks for parallel delivery (`"all"`).
39+
- Use `client.profiles().create()` for partial profile updates (it merges). Use `client.profiles().replace()` only when fully replacing all profile data.
40+
- Test and production use different API keys from the same workspace. Always confirm which environment before sending.
41+
- For transactional sends (OTP, orders, billing), pass an `Idempotency-Key` header via `.putAdditionalHeader("Idempotency-Key", value)` on the params builder to prevent duplicates.
42+
- Bulk sends are a 3-step flow: `client.bulk().createJob()``client.bulk().addUsers()``client.bulk().runJob()`.
43+
- `requestId` from a single-recipient send doubles as the `message_id`. For multi-recipient sends, each recipient gets a unique `message_id`.
44+
- Java uses the builder pattern for all params; all model classes are immutable.
45+
46+
## Concepts
47+
48+
- `template` — notification template ID from the Courier dashboard
49+
- `routing.method``"single"` = try channels in order until one succeeds; `"all"` = send on every channel simultaneously
50+
- `tenant_id` — multi-tenant context; affects brand and preference defaults for the message
51+
- `list_id` — send to all subscribers of a named list
52+
- `UserRecipient` — registered user whose profile has channel addresses
53+
- Ad-hoc recipients: pass email or phone directly in the `to` field (no stored profile needed)
54+
55+
## More context
56+
57+
- Full docs index: https://www.courier.com/docs/llms.txt
58+
- API reference: https://www.courier.com/docs/reference/get-started
59+
- MCP server: https://mcp.courier.com
60+
- Courier Skills (Cursor / Claude Code): https://github.com/trycourier/courier-skills

0 commit comments

Comments
 (0)