diff --git a/.env.example b/.env.example index 8efd89a..a633369 100644 --- a/.env.example +++ b/.env.example @@ -72,6 +72,8 @@ S3_COMPATIBLE_SECRET_KEY= S3_COMPATIBLE_API_URL= S3_COMPATIBLE_PUBLIC_URL= S3_COMPATIBLE_BUCKET=bytesend +# AWS S3 needs the bucket's region (e.g. us-east-1); R2 and MinIO accept "auto" +S3_COMPATIBLE_REGION=auto API_RATE_LIMIT=1 AUTH_EMAIL_RATE_LIMIT=5 diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index c9aa36a..096f224 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,7 +1,7 @@ blank_issues_enabled: false contact_links: - name: Security report - url: https://github.com/NodeByteLTD/ByteSend/blob/main/SECURITY.md + url: https://github.com/ByteSendApp/ByteSend/security/policy about: Please report vulnerabilities privately. - name: Community support (Discord) url: https://discord.gg/C2Q4GHXKQA diff --git a/.github/README.md b/.github/README.md index 2341afd..921e3aa 100644 --- a/.github/README.md +++ b/.github/README.md @@ -15,14 +15,14 @@ Website · Docs · API reference · - Releases · + Releases · Status · Discord

License: AGPL-3.0 - Latest release + Latest release Discord

@@ -78,7 +78,7 @@ Prefer another language or no code at all? Use the [Python](../packages/python-s **Self-hosted**: ByteSend is free to self-host under AGPL-3.0. You bring PostgreSQL, Redis and an AWS account with SES. ```bash -git clone https://github.com/NodeByteLTD/ByteSend.git +git clone https://github.com/ByteSendApp/ByteSend.git cd ByteSend cp docker/prod/.env.example docker/prod/.env # fill in your values docker compose -f docker/prod/compose.yml --env-file docker/prod/.env up -d @@ -120,7 +120,7 @@ The [local setup guide](https://docs.bytesend.cloud/get-started/local) walks thr | [`apps/docs`](../apps/docs) | Documentation site | | [`packages/sdk`](../packages/sdk) | TypeScript SDK (`bytesend-js`) | | [`packages/python-sdk`](../packages/python-sdk) | Python SDK (`bytesend`) | -| [`packages/go-sdk`](../packages/go-sdk) | Go SDK (`github.com/nodebyteltd/bytesend-go`) | +| [`packages/go-sdk`](../packages/go-sdk) | Go SDK (`github.com/ByteSendApp/ByteSend/packages/go-sdk`) | | [`packages/ui`](../packages/ui) | Shared UI components | | [`packages/email-editor`](../packages/email-editor) | Visual email template editor | diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 282ef51..f6d995f 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -93,12 +93,13 @@ jobs: APP_VERSION="develop" fi + GHCR="ghcr.io/$(echo "$GITHUB_REPOSITORY_OWNER" | tr '[:upper:]' '[:lower:]')" IMAGE_TAG_ARGS="" for TAG in $TAGS; do - IMAGE_TAG_ARGS="$IMAGE_TAG_ARGS -t bytesend/$APP-$BUILD_PLATFORM:$TAG -t ghcr.io/bytesend/$APP-$BUILD_PLATFORM:$TAG" + IMAGE_TAG_ARGS="$IMAGE_TAG_ARGS -t bytesend/$APP-$BUILD_PLATFORM:$TAG -t $GHCR/$APP-$BUILD_PLATFORM:$TAG" # Remove remote tags (single image or manifest list) so re-runs can safely republish. docker buildx imagetools rm bytesend/$APP-$BUILD_PLATFORM:$TAG 2>/dev/null || true - docker buildx imagetools rm ghcr.io/bytesend/$APP-$BUILD_PLATFORM:$TAG 2>/dev/null || true + docker buildx imagetools rm $GHCR/$APP-$BUILD_PLATFORM:$TAG 2>/dev/null || true done docker buildx build \ @@ -231,16 +232,17 @@ jobs: TAGS="$TAGS develop" fi + GHCR="ghcr.io/$(echo "$GITHUB_REPOSITORY_OWNER" | tr '[:upper:]' '[:lower:]')" for APP_NAME in bytesend smtp-proxy; do for TAG in $TAGS; do # Wait for both platform images to be available before creating manifest - wait_for_remote_image "ghcr.io/bytesend/$APP_NAME-amd64:$TAG" || exit 1 - wait_for_remote_image "ghcr.io/bytesend/$APP_NAME-arm64:$TAG" || exit 1 + wait_for_remote_image "$GHCR/$APP_NAME-amd64:$TAG" || exit 1 + wait_for_remote_image "$GHCR/$APP_NAME-arm64:$TAG" || exit 1 # buildx imagetools create is idempotent and updates the target tag in-place. docker buildx imagetools create \ - --tag ghcr.io/bytesend/$APP_NAME:$TAG \ - ghcr.io/bytesend/$APP_NAME-amd64:$TAG \ - ghcr.io/bytesend/$APP_NAME-arm64:$TAG + --tag $GHCR/$APP_NAME:$TAG \ + $GHCR/$APP_NAME-amd64:$TAG \ + $GHCR/$APP_NAME-arm64:$TAG done done diff --git a/.github/workflows/go-release.yml b/.github/workflows/go-release.yml new file mode 100644 index 0000000..d3636f5 --- /dev/null +++ b/.github/workflows/go-release.yml @@ -0,0 +1,72 @@ +name: Release Go SDK + +env: + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true" + +on: + push: + branches: + - main + paths: + - "packages/go-sdk/**" + workflow_dispatch: + +permissions: + contents: write + +concurrency: ${{ github.workflow }}-${{ github.ref }} + +jobs: + release: + runs-on: ubuntu-latest + defaults: + run: + working-directory: packages/go-sdk + steps: + - uses: actions/checkout@v5 + with: + fetch-depth: 0 + + - uses: actions/setup-go@v5 + with: + go-version-file: packages/go-sdk/go.mod + cache: false + + - name: Build and vet + run: | + go build ./... + go vet ./... + + - name: Read version + id: version + run: | + VERSION=$(sed -n 's/^const userAgent = "bytesend-go\/\(.*\)"$/\1/p' client.go) + if [ -z "$VERSION" ]; then + echo "Could not read the SDK version from client.go" >&2 + exit 1 + fi + # Go only resolves a module in a subdirectory from tags prefixed with that directory. + TAG="packages/go-sdk/v$VERSION" + echo "version=$VERSION" >> "$GITHUB_OUTPUT" + echo "tag=$TAG" >> "$GITHUB_OUTPUT" + if git rev-parse -q --verify "refs/tags/$TAG" >/dev/null; then + echo "exists=true" >> "$GITHUB_OUTPUT" + echo "$TAG already exists, skipping release" + else + echo "exists=false" >> "$GITHUB_OUTPUT" + fi + + - name: Tag release + if: steps.version.outputs.exists == 'false' + run: | + git tag "${{ steps.version.outputs.tag }}" + git push origin "${{ steps.version.outputs.tag }}" + + - name: Publish to the Go module proxy + if: steps.version.outputs.exists == 'false' + env: + GOPROXY: https://proxy.golang.org + run: | + MODULE=$(go list -m) + cd "$RUNNER_TEMP" + go list -m "$MODULE@v${{ steps.version.outputs.version }}" diff --git a/CHANGELOG.md b/CHANGELOG.md index af65f11..945e7d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 --- +## [0.4.3] - 2026-10-19 + +### Added +- `S3_COMPATIBLE_REGION` sets the storage bucket's region. AWS S3 needs the bucket's real region (e.g. `us-east-1`); R2 and MinIO keep working with the default `auto` +- **Python SDK 0.1.3**: `client.campaigns.delete()`, matching the Node.js and Go SDKs +- **Go SDK 0.3.3**: `ErrorResponse` now includes the HTTP `StatusCode` + +### Changed +- ByteSend now lives at [github.com/ByteSendApp/ByteSend](https://github.com/ByteSendApp/ByteSend); docs, READMEs, the site, the status page and package metadata link there +- **Go SDK module path** is now `github.com/ByteSendApp/ByteSend/packages/go-sdk`, matching where the code lives. Update imports from `github.com/nodebyteltd/bytesend-go`. A new workflow tags `packages/go-sdk/v` and publishes to the Go module proxy whenever the SDK version changes on `main` +- Docker images publish to the GitHub Container Registry under the repository owner's namespace (`ghcr.io/bytesendapp/…`) instead of a hard-coded `ghcr.io/bytesend/…` the workflow token couldn't push to +- **SDK-first docs**: the campaigns, campaign personalization, contact books, double opt-in, rate limits and error codes guides now show every example in Node.js, Python and Go, with cURL as a fallback tab, instead of cURL or raw `fetch` only + +### Fixed +- Changelog links render as links instead of raw Markdown +- Go SDK API errors now carry the real error code and message (e.g. `RATE_LIMITED`); previously every API error came back as `INTERNAL_SERVER_ERROR` with only the HTTP status text +- Docs examples that didn't match the SDKs: the contact books guide read `book.id` instead of the `{ data, error }` result and called `contacts.upsert` without a contact ID, and the error-codes guide used `try/catch` and a Python `APIError` class that don't exist +- Open stats shows exact email counts instead of rounded figures that looked inconsistent with the totals beneath them +- Em-dashes removed from site, dashboard, status page and docs copy + +--- + ## [0.4.2] - 2026-10-19 ### Added @@ -880,12 +902,19 @@ Initial public beta release of ByteSend: an all-in-one email infrastructure plat --- -[Unreleased]: https://github.com/nodebyte/bytesend/compare/v0.2.6...HEAD -[0.2.6]: https://github.com/nodebyte/bytesend/compare/v0.2.5...v0.2.6 -[0.2.5]: https://github.com/nodebyte/bytesend/compare/v0.2.4...v0.2.5 -[0.2.4]: https://github.com/nodebyte/bytesend/compare/v0.2.3...v0.2.4 -[0.2.3]: https://github.com/nodebyte/bytesend/compare/v0.2.2...v0.2.3 -[0.2.2]: https://github.com/nodebyte/bytesend/compare/v0.2.1...v0.2.2 -[0.2.1]: https://github.com/nodebyte/bytesend/compare/v0.2.0...v0.2.1 -[0.2.0]: https://github.com/nodebyte/bytesend/compare/v1.0.0-beta.1...v0.2.0 -[1.0.0-beta.1]: https://github.com/nodebyte/bytesend/releases/tag/v1.0.0-beta.1 +[Unreleased]: https://github.com/ByteSendApp/ByteSend/compare/v0.4.3...HEAD +[0.4.3]: https://github.com/ByteSendApp/ByteSend/compare/v0.4.2...v0.4.3 +[0.4.2]: https://github.com/ByteSendApp/ByteSend/compare/v0.4.1...v0.4.2 +[0.4.1]: https://github.com/ByteSendApp/ByteSend/compare/v0.4.0...v0.4.1 +[0.4.0]: https://github.com/ByteSendApp/ByteSend/compare/v0.3.2...v0.4.0 +[0.3.2]: https://github.com/ByteSendApp/ByteSend/compare/v0.3.1...v0.3.2 +[0.3.1]: https://github.com/ByteSendApp/ByteSend/compare/v0.3.0...v0.3.1 +[0.3.0]: https://github.com/ByteSendApp/ByteSend/compare/v0.2.6...v0.3.0 +[0.2.6]: https://github.com/ByteSendApp/ByteSend/compare/v0.2.5...v0.2.6 +[0.2.5]: https://github.com/ByteSendApp/ByteSend/compare/v0.2.4...v0.2.5 +[0.2.4]: https://github.com/ByteSendApp/ByteSend/compare/v0.2.3...v0.2.4 +[0.2.3]: https://github.com/ByteSendApp/ByteSend/compare/v0.2.2...v0.2.3 +[0.2.2]: https://github.com/ByteSendApp/ByteSend/compare/v0.2.1...v0.2.2 +[0.2.1]: https://github.com/ByteSendApp/ByteSend/compare/v0.2.0...v0.2.1 +[0.2.0]: https://github.com/ByteSendApp/ByteSend/compare/v1.0.0-beta.1...v0.2.0 +[1.0.0-beta.1]: https://github.com/ByteSendApp/ByteSend/releases/tag/v1.0.0-beta.1 diff --git a/apps/docs/docs.json b/apps/docs/docs.json index c24ed1c..87f3067 100644 --- a/apps/docs/docs.json +++ b/apps/docs/docs.json @@ -202,7 +202,7 @@ "anchors": [ { "anchor": "GitHub", - "href": "https://github.com/NodeByteLTD/ByteSend", + "href": "https://github.com/ByteSendApp/ByteSend", "icon": "github" }, { @@ -253,7 +253,7 @@ "footer": { "socials": { "x": "https://x.com/TryByteSend", - "github": "https://github.com/NodeByteLTD/ByteSend", + "github": "https://github.com/ByteSendApp/ByteSend", "discord": "https://discord.gg/C2Q4GHXKQA" } }, diff --git a/apps/docs/get-started/examples.mdx b/apps/docs/get-started/examples.mdx index 1214932..bc79fc9 100644 --- a/apps/docs/get-started/examples.mdx +++ b/apps/docs/get-started/examples.mdx @@ -385,7 +385,7 @@ See the [Python guide](/get-started/python) for error handling, idempotency and ## Go ```sh -go get github.com/nodebyteltd/bytesend-go +go get github.com/ByteSendApp/ByteSend/packages/go-sdk ``` ```go main.go @@ -396,7 +396,7 @@ import ( "fmt" "log" - bytesend "github.com/nodebyteltd/bytesend-go" + bytesend "github.com/ByteSendApp/ByteSend/packages/go-sdk" ) func main() { diff --git a/apps/docs/get-started/go.mdx b/apps/docs/get-started/go.mdx index 5359f80..141728e 100644 --- a/apps/docs/get-started/go.mdx +++ b/apps/docs/get-started/go.mdx @@ -15,7 +15,7 @@ icon: golang Install the ByteSend Go SDK: ```bash -go get github.com/nodebyteltd/bytesend-go +go get github.com/ByteSendApp/ByteSend/packages/go-sdk ``` ## Quick Start @@ -28,7 +28,7 @@ import ( "fmt" "log" - bytesend "github.com/nodebyteltd/bytesend-go" + bytesend "github.com/ByteSendApp/ByteSend/packages/go-sdk" ) func main() { @@ -80,7 +80,7 @@ import ( "net/http" "time" - bytesend "github.com/nodebyteltd/bytesend-go" + bytesend "github.com/ByteSendApp/ByteSend/packages/go-sdk" ) client, err := bytesend.NewClient( @@ -104,7 +104,7 @@ The default base URL is `https://bytesend.cloud/api/v1`. For self-hosted deploym ## Error Handling -All service methods return a single `error`. API errors are returned as `*ErrorResponse`. Use `errors.As` to distinguish API errors from network or encoding errors: +All service methods return a single `error`. API errors are returned as `*ErrorResponse`, with the API's error `Code` (such as `RATE_LIMITED`), `Message` and HTTP `StatusCode`. Use `errors.As` to distinguish API errors from network or encoding errors: ```go import "errors" @@ -114,7 +114,7 @@ if err != nil { var apiErr *bytesend.ErrorResponse if errors.As(err, &apiErr) { // API error (validation, auth, rate limit, etc.) - fmt.Printf("API error %s: %s\n", apiErr.Code, apiErr.Message) + fmt.Printf("API error %d %s: %s\n", apiErr.StatusCode, apiErr.Code, apiErr.Message) } else { // Network, timeout, or encoding error log.Fatal(err) @@ -426,4 +426,4 @@ fmt.Printf("Complaint rate: %.2f%%\n", resp.ComplaintRate*100) ## More Information -For complete SDK documentation and examples, see the [GitHub repository](https://github.com/nodebyteltd/bytesend-go). +For complete SDK documentation and examples, see the [GitHub repository](https://github.com/ByteSendApp/ByteSend/tree/main/packages/go-sdk). diff --git a/apps/docs/get-started/local.mdx b/apps/docs/get-started/local.mdx index 80cf669..9c56e5c 100644 --- a/apps/docs/get-started/local.mdx +++ b/apps/docs/get-started/local.mdx @@ -32,7 +32,7 @@ packages/ - Click the **Fork** button on [GitHub](https://github.com/NodeByteLTD/ByteSend) to fork the repo. + Click the **Fork** button on [GitHub](https://github.com/ByteSendApp/ByteSend) to fork the repo. ```bash diff --git a/apps/docs/guides/campaign-personalization.mdx b/apps/docs/guides/campaign-personalization.mdx index 47947b9..63f0e96 100644 --- a/apps/docs/guides/campaign-personalization.mdx +++ b/apps/docs/guides/campaign-personalization.mdx @@ -112,11 +112,38 @@ This renders `there` when `firstName` is empty. ## Using the API + +The examples assume a client set up as in the [Node.js](/get-started/nodejs), [Python](/get-started/python) or [Go](/get-started/go) guide. Every SDK reads `BYTESEND_API_KEY` from the environment. + + ### Create a contact book with variables -```bash + + +```ts Node.js +const { data: book } = await bytesend.contactBooks.create({ + name: "Customers", + variables: ["company", "plan", "registrationCode"], +}); +``` + +```python Python +book, _ = client.contact_books.create({ + "name": "Customers", + "variables": ["company", "plan", "registrationCode"], +}) +``` + +```go Go +book, err := client.ContactBooks.Create(ctx, bytesend.CreateContactBookPayload{ + Name: "Customers", + Variables: []string{"company", "plan", "registrationCode"}, +}) +``` + +```bash cURL curl -X POST https://bytesend.cloud/api/v1/contactBooks \ - -H "Authorization: Bearer bs_your_api_key" \ + -H "Authorization: Bearer $BYTESEND_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Customers", @@ -124,11 +151,51 @@ curl -X POST https://bytesend.cloud/api/v1/contactBooks \ }' ``` + + ### Create a contact with variable values -```bash + + +```ts Node.js +await bytesend.contacts.create(contactBookId, { + email: "jane@example.com", + firstName: "Jane", + properties: { + company: "Acme", + plan: "Pro", + registrationCode: "WELCOME-2026", + }, +}); +``` + +```python Python +client.contacts.create(contact_book_id, { + "email": "jane@example.com", + "firstName": "Jane", + "properties": { + "company": "Acme", + "plan": "Pro", + "registrationCode": "WELCOME-2026", + }, +}) +``` + +```go Go +_, err := client.Contacts.Create(ctx, contactBookID, bytesend.CreateContactPayload{ + Email: "jane@example.com", + FirstName: "Jane", + Properties: map[string]string{ + "company": "Acme", + "plan": "Pro", + "registrationCode": "WELCOME-2026", + }, +}) +``` + +```bash cURL curl -X POST https://bytesend.cloud/api/v1/contactBooks/{contactBookId}/contacts \ - -H "Authorization: Bearer bs_your_api_key" \ + -H "Authorization: Bearer $BYTESEND_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "email": "jane@example.com", @@ -141,11 +208,45 @@ curl -X POST https://bytesend.cloud/api/v1/contactBooks/{contactBookId}/contacts }' ``` + + ### Create a campaign that uses variables -```bash + + +```ts Node.js +await bytesend.campaigns.create({ + name: "Welcome campaign", + from: "Acme ", + subject: "Welcome to {{company}}", + contactBookId, + html: "

Hi {{firstName,fallback=there}}, your plan is {{plan}}.

", +}); +``` + +```python Python +client.campaigns.create({ + "name": "Welcome campaign", + "from": "Acme ", + "subject": "Welcome to {{company}}", + "contactBookId": contact_book_id, + "html": "

Hi {{firstName,fallback=there}}, your plan is {{plan}}.

", +}) +``` + +```go Go +_, err := client.Campaigns.Create(ctx, bytesend.CreateCampaignPayload{ + Name: "Welcome campaign", + From: "Acme ", + Subject: "Welcome to {{company}}", + ContactBookID: contactBookID, + HTML: "

Hi {{firstName,fallback=there}}, your plan is {{plan}}.

", +}) +``` + +```bash cURL curl -X POST https://bytesend.cloud/api/v1/campaigns \ - -H "Authorization: Bearer bs_your_api_key" \ + -H "Authorization: Bearer $BYTESEND_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Welcome campaign", @@ -156,6 +257,8 @@ curl -X POST https://bytesend.cloud/api/v1/campaigns \ }' ``` +
+ ## Best practices | Best practice | Why it helps | diff --git a/apps/docs/guides/campaigns.mdx b/apps/docs/guides/campaigns.mdx index 0c764ec..93d2ec2 100644 --- a/apps/docs/guides/campaigns.mdx +++ b/apps/docs/guides/campaigns.mdx @@ -47,9 +47,50 @@ Campaigns are different from **transactional emails** (which go to a single reci ### Via the API -```bash + +The examples assume a client set up as in the [Node.js](/get-started/nodejs), [Python](/get-started/python) or [Go](/get-started/go) guide. Every SDK reads `BYTESEND_API_KEY` from the environment. + + + + +```ts Node.js +const { data, error } = await bytesend.campaigns.create({ + name: "June Newsletter", + subject: "What's new in June", + from: "hello@example.com", + contactBookId: "clzeydgeygff", +}); + +if (error) throw new Error(error.message); +console.log("Created campaign", data?.id); +``` + +```python Python +campaign, _ = client.campaigns.create({ + "name": "June Newsletter", + "subject": "What's new in June", + "from": "hello@example.com", + "contactBookId": "clzeydgeygff", +}) +print("Created campaign", campaign["id"]) +``` + +```go Go +campaign, err := client.Campaigns.Create(ctx, bytesend.CreateCampaignPayload{ + Name: "June Newsletter", + Subject: "What's new in June", + From: "hello@example.com", + ContactBookID: "clzeydgeygff", +}) +if err != nil { + log.Fatal(err) +} +fmt.Println("Created campaign", campaign.ID) +``` + +```bash cURL curl -X POST https://bytesend.cloud/api/v1/campaigns \ - -H "Authorization: Bearer bs_your_api_key" \ + -H "Authorization: Bearer $BYTESEND_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "June Newsletter", @@ -59,6 +100,8 @@ curl -X POST https://bytesend.cloud/api/v1/campaigns \ }' ``` + + --- ## Campaign States @@ -78,38 +121,99 @@ curl -X POST https://bytesend.cloud/api/v1/campaigns \ Schedule a campaign to send at a future time: -```bash + + +```ts Node.js +await bytesend.campaigns.schedule(campaignId, { + scheduledAt: "2026-07-01T09:00:00Z", +}); +``` + +```python Python +client.campaigns.schedule(campaign_id, {"scheduledAt": "2026-07-01T09:00:00Z"}) +``` + +```go Go +_, err := client.Campaigns.Schedule(ctx, campaignID, bytesend.ScheduleCampaignPayload{ + ScheduledAt: "2026-07-01T09:00:00Z", +}) +``` + +```bash cURL curl -X POST https://bytesend.cloud/api/v1/campaigns/{campaignId}/schedule \ - -H "Authorization: Bearer bs_your_api_key" \ + -H "Authorization: Bearer $BYTESEND_API_KEY" \ -H "Content-Type: application/json" \ -d '{"scheduledAt": "2026-07-01T09:00:00Z"}' ``` + + Campaigns can be re-scheduled or cancelled at any time before the send starts. ### Cancelling a scheduled campaign -```bash + + +```ts Node.js +await bytesend.campaigns.delete(campaignId); +``` + +```python Python +client.campaigns.delete(campaign_id) +``` + +```go Go +_, err := client.Campaigns.Delete(ctx, campaignID) +``` + +```bash cURL curl -X DELETE https://bytesend.cloud/api/v1/campaigns/{campaignId} \ - -H "Authorization: Bearer bs_your_api_key" + -H "Authorization: Bearer $BYTESEND_API_KEY" ``` + + --- ## Pausing and Resuming If a campaign is in progress and you need to stop it (for example, you spotted a typo), you can pause it: -```bash + + +```ts Node.js +await bytesend.campaigns.pause(campaignId); + +// Later, once the issue is fixed +await bytesend.campaigns.resume(campaignId); +``` + +```python Python +client.campaigns.pause(campaign_id) + +# Later, once the issue is fixed +client.campaigns.resume(campaign_id) +``` + +```go Go +_, err := client.Campaigns.Pause(ctx, campaignID) + +// Later, once the issue is fixed +_, err = client.Campaigns.Resume(ctx, campaignID) +``` + +```bash cURL # Pause curl -X POST https://bytesend.cloud/api/v1/campaigns/{campaignId}/pause \ - -H "Authorization: Bearer bs_your_api_key" + -H "Authorization: Bearer $BYTESEND_API_KEY" # Resume curl -X POST https://bytesend.cloud/api/v1/campaigns/{campaignId}/resume \ - -H "Authorization: Bearer bs_your_api_key" + -H "Authorization: Bearer $BYTESEND_API_KEY" ``` + + Emails already sent before the pause are not recalled. Pausing stops further sends to remaining recipients. diff --git a/apps/docs/guides/contact-books.mdx b/apps/docs/guides/contact-books.mdx index d5631fd..5bbe7d7 100644 --- a/apps/docs/guides/contact-books.mdx +++ b/apps/docs/guides/contact-books.mdx @@ -27,19 +27,44 @@ Contact books are the foundation of ByteSend's marketing features. You need at l ### Via the API -```bash + +The examples assume a client set up as in the [Node.js](/get-started/nodejs), [Python](/get-started/python) or [Go](/get-started/go) guide. Every SDK reads `BYTESEND_API_KEY` from the environment. + + + + +```ts Node.js +const { data: book, error } = await bytesend.contactBooks.create({ + name: "Newsletter Subscribers", +}); + +if (error) throw new Error(error.message); +console.log(book?.id); // keep this id for adding contacts +``` + +```python Python +book, _ = client.contact_books.create({"name": "Newsletter Subscribers"}) +print(book["id"]) # keep this id for adding contacts +``` + +```go Go +book, err := client.ContactBooks.Create(ctx, bytesend.CreateContactBookPayload{ + Name: "Newsletter Subscribers", +}) +if err != nil { + log.Fatal(err) +} +fmt.Println(book.ID) // keep this id for adding contacts +``` + +```bash cURL curl -X POST https://bytesend.cloud/api/v1/contactBooks \ - -H "Authorization: Bearer bs_your_api_key" \ + -H "Authorization: Bearer $BYTESEND_API_KEY" \ -H "Content-Type: application/json" \ -d '{"name": "Newsletter Subscribers"}' ``` -```typescript -const book = await bytesend.contactBooks.create({ - name: "Newsletter Subscribers", -}); -console.log(book.id); // keep this id for adding contacts -``` + --- @@ -49,7 +74,9 @@ Contacts can be added one at a time, in bulk, or imported from a CSV. ### Single contact -```typescript + + +```ts Node.js await bytesend.contacts.create(contactBookId, { email: "jane@example.com", firstName: "Jane", @@ -57,11 +84,38 @@ await bytesend.contacts.create(contactBookId, { }); ``` +```python Python +client.contacts.create(contact_book_id, { + "email": "jane@example.com", + "firstName": "Jane", + "lastName": "Smith", +}) +``` + +```go Go +_, err := client.Contacts.Create(ctx, contactBookID, bytesend.CreateContactPayload{ + Email: "jane@example.com", + FirstName: "Jane", + LastName: "Smith", +}) +``` + +```bash cURL +curl -X POST https://bytesend.cloud/api/v1/contactBooks/{contactBookId}/contacts \ + -H "Authorization: Bearer $BYTESEND_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{"email": "jane@example.com", "firstName": "Jane", "lastName": "Smith"}' +``` + + + ### Bulk import (API) Use the bulk create endpoint to add up to 1,000 contacts in one request: -```typescript + + +```ts Node.js await bytesend.contacts.bulkCreate(contactBookId, [ { email: "alice@example.com", firstName: "Alice" }, { email: "bob@example.com", firstName: "Bob" }, @@ -69,6 +123,35 @@ await bytesend.contacts.bulkCreate(contactBookId, [ ]); ``` +```python Python +client.contacts.bulk_create(contact_book_id, [ + {"email": "alice@example.com", "firstName": "Alice"}, + {"email": "bob@example.com", "firstName": "Bob"}, + {"email": "carol@example.com", "firstName": "Carol"}, +]) +``` + +```go Go +_, err := client.Contacts.BulkCreate(ctx, contactBookID, []bytesend.CreateContactPayload{ + {Email: "alice@example.com", FirstName: "Alice"}, + {Email: "bob@example.com", FirstName: "Bob"}, + {Email: "carol@example.com", FirstName: "Carol"}, +}) +``` + +```bash cURL +curl -X POST https://bytesend.cloud/api/v1/contactBooks/{contactBookId}/contacts/bulk \ + -H "Authorization: Bearer $BYTESEND_API_KEY" \ + -H "Content-Type: application/json" \ + -d '[ + {"email": "alice@example.com", "firstName": "Alice"}, + {"email": "bob@example.com", "firstName": "Bob"}, + {"email": "carol@example.com", "firstName": "Carol"} + ]' +``` + + + ### CSV import (dashboard) 1. Go to your contact book → **Import** @@ -98,7 +181,9 @@ Contacts with **Pending** or **Unsubscribed** status are excluded from campaign Beyond the standard `email`, `firstName`, and `lastName` fields, contacts support custom key-value properties for anything relevant to your audience: plan tier, signup source, account ID, etc. -```typescript + + +```ts Node.js await bytesend.contacts.create(contactBookId, { email: "alice@example.com", firstName: "Alice", @@ -110,34 +195,120 @@ await bytesend.contacts.create(contactBookId, { }); ``` +```python Python +client.contacts.create(contact_book_id, { + "email": "alice@example.com", + "firstName": "Alice", + "properties": { + "plan": "pro", + "signupSource": "landing-page", + "userId": "usr_abc123", + }, +}) +``` + +```go Go +_, err := client.Contacts.Create(ctx, contactBookID, bytesend.CreateContactPayload{ + Email: "alice@example.com", + FirstName: "Alice", + Properties: map[string]string{ + "plan": "pro", + "signupSource": "landing-page", + "userId": "usr_abc123", + }, +}) +``` + +```bash cURL +curl -X POST https://bytesend.cloud/api/v1/contactBooks/{contactBookId}/contacts \ + -H "Authorization: Bearer $BYTESEND_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "email": "alice@example.com", + "firstName": "Alice", + "properties": {"plan": "pro", "signupSource": "landing-page", "userId": "usr_abc123"} + }' +``` + + + Custom properties can then be used in [campaign personalization](/guides/campaign-personalization) via `{{plan}}`, `{{signupSource}}`, etc. --- ## Upserting Contacts -The upsert endpoint creates a contact if they don't exist, or updates their record if they do. This is ideal for syncing contacts from your app on signup or profile update: +Contacts are matched by email address within a contact book, so creating a contact that already exists updates their record instead of failing. Call it on every signup or profile change to keep the book in sync: + + -```typescript -await bytesend.contacts.upsert(contactBookId, { +```ts Node.js +await bytesend.contacts.create(contactBookId, { email: "alice@example.com", firstName: "Alice", properties: { plan: "pro" }, }); ``` +```python Python +client.contacts.create(contact_book_id, { + "email": "alice@example.com", + "firstName": "Alice", + "properties": {"plan": "pro"}, +}) +``` + +```go Go +_, err := client.Contacts.Create(ctx, contactBookID, bytesend.CreateContactPayload{ + Email: "alice@example.com", + FirstName: "Alice", + Properties: map[string]string{"plan": "pro"}, +}) +``` + +```bash cURL +curl -X POST https://bytesend.cloud/api/v1/contactBooks/{contactBookId}/contacts \ + -H "Authorization: Bearer $BYTESEND_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{"email": "alice@example.com", "firstName": "Alice", "properties": {"plan": "pro"}}' +``` + + + --- ## Unsubscribing Contacts When a recipient unsubscribes, update their status immediately: -```typescript + + +```ts Node.js await bytesend.contacts.update(contactBookId, contactId, { subscribed: false, }); ``` +```python Python +client.contacts.update(contact_book_id, contact_id, {"subscribed": False}) +``` + +```go Go +subscribed := false +_, err := client.Contacts.Update(ctx, contactBookID, contactID, bytesend.UpdateContactPayload{ + Subscribed: &subscribed, +}) +``` + +```bash cURL +curl -X PATCH https://bytesend.cloud/api/v1/contactBooks/{contactBookId}/contacts/{contactId} \ + -H "Authorization: Bearer $BYTESEND_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{"subscribed": false}' +``` + + + If you handle unsubscribes via webhooks (e.g., reading from `email.complained`), do this automatically in your webhook handler so your list stays clean. --- diff --git a/apps/docs/guides/double-opt-in.mdx b/apps/docs/guides/double-opt-in.mdx index 42beb08..da134dd 100644 --- a/apps/docs/guides/double-opt-in.mdx +++ b/apps/docs/guides/double-opt-in.mdx @@ -49,11 +49,45 @@ Double opt-in requires new contacts to confirm their email address before they b ### Via the API + +The examples assume a client set up as in the [Node.js](/get-started/nodejs), [Python](/get-started/python) or [Go](/get-started/go) guide. Every SDK reads `BYTESEND_API_KEY` from the environment. + + Create a contact book with double opt-in enabled: -```bash + + +```ts Node.js +await bytesend.contactBooks.create({ + name: "Newsletter Subscribers", + doubleOptInEnabled: true, + doubleOptInFrom: "Newsletter ", + doubleOptInSubject: "Please confirm your subscription", +}); +``` + +```python Python +client.contact_books.create({ + "name": "Newsletter Subscribers", + "doubleOptInEnabled": True, + "doubleOptInFrom": "Newsletter ", + "doubleOptInSubject": "Please confirm your subscription", +}) +``` + +```go Go +enabled := true +_, err := client.ContactBooks.Create(ctx, bytesend.CreateContactBookPayload{ + Name: "Newsletter Subscribers", + DoubleOptInEnabled: &enabled, + DoubleOptInFrom: "Newsletter ", + DoubleOptInSubject: "Please confirm your subscription", +}) +``` + +```bash cURL curl -X POST https://bytesend.cloud/api/v1/contactBooks \ - -H "Authorization: Bearer bs_your_api_key" \ + -H "Authorization: Bearer $BYTESEND_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Newsletter Subscribers", @@ -63,17 +97,38 @@ curl -X POST https://bytesend.cloud/api/v1/contactBooks \ }' ``` + + Or enable it on an existing contact book: -```bash + + +```ts Node.js +await bytesend.contactBooks.update(contactBookId, { + doubleOptInEnabled: true, +}); +``` + +```python Python +client.contact_books.update(contact_book_id, {"doubleOptInEnabled": True}) +``` + +```go Go +enabled := true +_, err := client.ContactBooks.Update(ctx, contactBookID, bytesend.UpdateContactBookPayload{ + DoubleOptInEnabled: &enabled, +}) +``` + +```bash cURL curl -X PATCH https://bytesend.cloud/api/v1/contactBooks/{contactBookId} \ - -H "Authorization: Bearer bs_your_api_key" \ + -H "Authorization: Bearer $BYTESEND_API_KEY" \ -H "Content-Type: application/json" \ - -d '{ - "doubleOptInEnabled": true - }' + -d '{"doubleOptInEnabled": true}' ``` + + ## Contact statuses When double opt-in is enabled, contacts have three possible statuses: diff --git a/apps/docs/guides/error-codes.mdx b/apps/docs/guides/error-codes.mdx index 375ba07..0c3a05c 100644 --- a/apps/docs/guides/error-codes.mdx +++ b/apps/docs/guides/error-codes.mdx @@ -185,50 +185,30 @@ An unexpected error occurred on the ByteSend server. These are rare and typicall ## Handling Errors in Code -### JavaScript / TypeScript +Each SDK surfaces the `code` and `message` from the error body, so you can branch on the code: -```typescript -import { ByteSend } from "bytesend-js"; + -const bytesend = new ByteSend(process.env.BYTESEND_API_KEY!); - -try { - const email = await bytesend.emails.send({ - from: "hello@example.com", - to: "recipient@example.com", - subject: "Hello", - html: "

Hello!

", - }); - console.log("Sent:", email.id); -} catch (error) { - if (error instanceof Error) { - console.error("Failed:", error.message); - } -} -``` +```ts Node.js +import { ByteSend } from "bytesend-js"; -### Handling specific codes (raw fetch) +const bytesend = new ByteSend(); -```typescript -const response = await fetch("https://bytesend.cloud/api/v1/emails", { - method: "POST", - headers: { - Authorization: `Bearer ${process.env.BYTESEND_API_KEY}`, - "Content-Type": "application/json", - }, - body: JSON.stringify({ from: "...", to: "...", subject: "...", html: "..." }), +// SDK methods return { data, error } instead of throwing. +const { data, error } = await bytesend.emails.send({ + from: "hello@example.com", + to: "recipient@example.com", + subject: "Hello", + html: "

Hello!

", }); -if (!response.ok) { - const { error } = await response.json(); - +if (error) { switch (error.code) { case "UNAUTHORIZED": console.error("Check your API key"); break; case "RATE_LIMITED": - const retryAfter = response.headers.get("Retry-After"); - console.error(`Rate limited. Retry in ${retryAfter}s`); + console.error("Rate limited, retry shortly"); break; case "BAD_REQUEST": console.error("Invalid request:", error.message); @@ -236,35 +216,65 @@ if (!response.ok) { default: console.error(`API error ${error.code}: ${error.message}`); } +} else { + console.log("Queued:", data?.emailId); } ``` -### Python - -```python -import bytesend -import time +```python Python +from bytesend import ByteSend, ByteSendHTTPError -client = bytesend.ByteSend(api_key=os.environ["BYTESEND_API_KEY"]) +client = ByteSend() # raises ByteSendHTTPError on API errors by default try: - email = client.emails.send( - from_="hello@example.com", - to="recipient@example.com", - subject="Hello", - html="

Hello!

", - ) - print(f"Sent: {email.id}") -except bytesend.APIError as e: - if e.code == "RATE_LIMITED": - retry_after = e.headers.get("Retry-After", 1) - time.sleep(int(retry_after)) - elif e.code == "UNAUTHORIZED": - print("Invalid API key") + email, _ = client.emails.send({ + "from": "hello@example.com", + "to": "recipient@example.com", + "subject": "Hello", + "html": "

Hello!

", + }) + print("Queued:", email["emailId"]) +except ByteSendHTTPError as err: + code = err.error.get("code") + if code == "RATE_LIMITED": + print("Rate limited, retry shortly") + elif code == "UNAUTHORIZED": + print("Check your API key") else: - print(f"Error {e.code}: {e.message}") + print(f"API error {code}: {err.error.get('message')}") ``` +```go Go +resp, err := client.Emails.Create(ctx, bytesend.SendEmailPayload{ + From: "hello@example.com", + To: []string{"recipient@example.com"}, + Subject: "Hello", + HTML: "

Hello!

", +}) + +var apiErr *bytesend.ErrorResponse +switch { +case err == nil: + fmt.Println("Queued:", resp.EmailID) +case errors.As(err, &apiErr) && apiErr.Code == "RATE_LIMITED": + fmt.Println("Rate limited, retry shortly") +case errors.As(err, &apiErr) && apiErr.Code == "UNAUTHORIZED": + fmt.Println("Check your API key") +case errors.As(err, &apiErr): + fmt.Printf("API error %s: %s\n", apiErr.Code, apiErr.Message) +default: + log.Fatal(err) // network error +} +``` + +```bash cURL +# Error responses use the shape shown above; -i prints the status line and headers +curl -i https://bytesend.cloud/api/v1/emails/does-not-exist \ + -H "Authorization: Bearer $BYTESEND_API_KEY" +``` + +
+ --- ## Summary Table diff --git a/apps/docs/guides/rate-limits.mdx b/apps/docs/guides/rate-limits.mdx index bdf2cb6..004b1a9 100644 --- a/apps/docs/guides/rate-limits.mdx +++ b/apps/docs/guides/rate-limits.mdx @@ -54,57 +54,72 @@ When you receive a `429 RATE_LIMITED` response, wait for the number of seconds s } ``` -### Retry with backoff (TypeScript) - -```typescript -async function sendWithRetry(payload: object, maxRetries = 3): Promise { - for (let attempt = 0; attempt <= maxRetries; attempt++) { - const response = await fetch("https://bytesend.cloud/api/v1/emails", { - method: "POST", - headers: { - Authorization: `Bearer ${process.env.BYTESEND_API_KEY}`, - "Content-Type": "application/json", - }, - body: JSON.stringify(payload), - }); - - if (response.status !== 429) return response; - - if (attempt === maxRetries) throw new Error("Max retries reached"); - - const retryAfter = parseInt(response.headers.get("Retry-After") ?? "1", 10); - await new Promise((r) => setTimeout(r, retryAfter * 1000)); - } +### Retrying in your code + +The SDKs report a rate-limited request as a `RATE_LIMITED` error rather than retrying for you, so wrap sends that might burst in a short retry loop: + + + +```ts Node.js +import { ByteSend } from "bytesend-js"; + +const bytesend = new ByteSend(); - throw new Error("Unreachable"); +type SendPayload = Parameters[0]; + +async function sendWithRetry(payload: SendPayload, maxRetries = 3) { + for (let attempt = 0; ; attempt++) { + const result = await bytesend.emails.send(payload); + if (result.error?.code !== "RATE_LIMITED" || attempt === maxRetries) { + return result; + } + await new Promise((resolve) => setTimeout(resolve, 2 ** attempt * 1000)); + } } ``` -### Retry with backoff (Python) - -```python +```python Python import time -import requests +from bytesend import ByteSend, ByteSendHTTPError -def send_with_retry(payload: dict, max_retries: int = 3) -> dict: - headers = { - "Authorization": f"Bearer {os.environ['BYTESEND_API_KEY']}", - "Content-Type": "application/json", - } +client = ByteSend() + +def send_with_retry(payload: dict, max_retries: int = 3): for attempt in range(max_retries + 1): - response = requests.post( - "https://bytesend.cloud/api/v1/emails", - json=payload, - headers=headers, - ) - if response.status_code != 429: - return response.json() - if attempt == max_retries: - raise Exception("Max retries reached") - retry_after = int(response.headers.get("Retry-After", 1)) - time.sleep(retry_after) + try: + return client.emails.send(payload) + except ByteSendHTTPError as err: + if err.status_code != 429 or attempt == max_retries: + raise + time.sleep(2 ** attempt) +``` + +```go Go +func sendWithRetry(ctx context.Context, client *bytesend.Client, payload bytesend.SendEmailPayload) (bytesend.CreateEmailResponse, error) { + const maxRetries = 3 + for attempt := 0; ; attempt++ { + resp, err := client.Emails.Create(ctx, payload) + var apiErr *bytesend.ErrorResponse + if !errors.As(err, &apiErr) || apiErr.StatusCode != http.StatusTooManyRequests || attempt == maxRetries { + return resp, err + } + time.Sleep(time.Duration(1<Hi

"}' +``` + +
+ +When calling the REST API directly, wait for the number of seconds in the `Retry-After` header instead of a fixed backoff. + --- ## Best Practices diff --git a/apps/docs/introduction.mdx b/apps/docs/introduction.mdx index 13496df..a6eabfa 100644 --- a/apps/docs/introduction.mdx +++ b/apps/docs/introduction.mdx @@ -276,7 +276,7 @@ Want to run ByteSend on your own infrastructure? ## Quick Links -- [View GitHub Repository](https://github.com/NodeByteLTD/ByteSend) +- [View GitHub Repository](https://github.com/ByteSendApp/ByteSend) - [Join Community Discord](https://discord.gg/C2Q4GHXKQA) - [Follow on Twitter](https://twitter.com/TryByteSend) - [Dashboard](https://bytesend.cloud) @@ -286,4 +286,4 @@ Want to run ByteSend on your own infrastructure? - Browse the [API Reference](/api-reference/introduction) - Check out [Integration Guides](/guides/webhooks) - Join our [Community Discord](https://discord.gg/C2Q4GHXKQA) -- View [GitHub Discussions](https://github.com/NodeByteLTD/ByteSend/discussions) +- View [GitHub Discussions](https://github.com/ByteSendApp/ByteSend/discussions) diff --git a/apps/docs/self-hosting/docker.mdx b/apps/docs/self-hosting/docker.mdx index 58dfa04..e96cfe0 100644 --- a/apps/docs/self-hosting/docker.mdx +++ b/apps/docs/self-hosting/docker.mdx @@ -18,7 +18,7 @@ This guide covers the fastest path to a running ByteSend instance using Docker C ## 1. Clone the repository ```bash -git clone https://github.com/NodeByteLTD/ByteSend.git +git clone https://github.com/ByteSendApp/ByteSend.git cd ByteSend ``` diff --git a/apps/docs/self-hosting/overview.mdx b/apps/docs/self-hosting/overview.mdx index 9d98fe8..dc79bc5 100644 --- a/apps/docs/self-hosting/overview.mdx +++ b/apps/docs/self-hosting/overview.mdx @@ -40,7 +40,7 @@ newgrp docker ### 2. Clone the repository ```bash -git clone https://github.com/NodeByteLTD/ByteSend.git +git clone https://github.com/ByteSendApp/ByteSend.git cd ByteSend ``` @@ -154,7 +154,7 @@ sudo systemctl start redis-server ### 4. Clone and install ```bash -git clone https://github.com/NodeByteLTD/ByteSend.git +git clone https://github.com/ByteSendApp/ByteSend.git cd bytesend pnpm install ``` @@ -270,6 +270,7 @@ sudo journalctl -u bytesend -f | `DISCORD_CLIENT_ID` / `DISCORD_CLIENT_SECRET` | No | Discord OAuth credentials | | `GOOGLE_CLIENT_ID` / `GOOGLE_CLIENT_SECRET` | No | Google OAuth credentials | | `S3_COMPATIBLE_*` | No | S3-compatible storage (defaults to bundled MinIO) | +| `S3_COMPATIBLE_REGION` | No | Bucket region. AWS S3 needs the real region (e.g. `us-east-1`); R2 and MinIO use the default `auto` | | `SMTP_HOST` / `SMTP_USER` | No | External SMTP relay for account emails | | `ADMIN_EMAIL` | No | Grants admin panel access to this address | | `DISCORD_WEBHOOK_URL` | No | Discord webhook for platform alerts (signups, blocked teams, blocklisted domains) | diff --git a/apps/docs/self-hosting/smtp-server.mdx b/apps/docs/self-hosting/smtp-server.mdx index 3f69496..8ff94f3 100644 --- a/apps/docs/self-hosting/smtp-server.mdx +++ b/apps/docs/self-hosting/smtp-server.mdx @@ -5,7 +5,7 @@ description: "An end-to-end guide on how to self-host the ByteSend SMTP Server." The ByteSend SMTP Server is a lightweight Node.js application inside the ByteSend monorepo that forwards incoming SMTP connections to the ByteSend API. It can be deployed on the same host as ByteSend or on a separate machine. -**Source path:** [`apps/smtp-server`](https://github.com/NodeByteLTD/ByteSend/tree/main/apps/smtp-server) +**Source path:** [`apps/smtp-server`](https://github.com/ByteSendApp/ByteSend/tree/main/apps/smtp-server) --- @@ -110,7 +110,7 @@ If you prefer to build the image locally: 1. **Clone the ByteSend repository:** ```bash - git clone https://github.com/NodeByteLTD/ByteSend.git + git clone https://github.com/ByteSendApp/ByteSend.git cd ByteSend/apps/smtp-server ``` @@ -143,7 +143,7 @@ If you prefer to build the image locally: 1. **Clone and install:** ```bash - git clone https://github.com/NodeByteLTD/ByteSend.git + git clone https://github.com/ByteSendApp/ByteSend.git cd ByteSend/apps/smtp-server npm install ``` @@ -301,7 +301,7 @@ Save as `/etc/systemd/system/bytesend-smtp.service`: ```ini [Unit] Description=ByteSend SMTP Server -Documentation=https://github.com/NodeByteLTD/ByteSend/tree/main/apps/smtp-server +Documentation=https://github.com/ByteSendApp/ByteSend/tree/main/apps/smtp-server After=network.target [Service] @@ -352,7 +352,7 @@ sudo chown smtp:smtp /opt/bytesend-smtp/logs # Clone and build cd /opt/bytesend-smtp -sudo -u smtp HOME=/opt/bytesend-smtp git clone https://github.com/NodeByteLTD/ByteSend.git . +sudo -u smtp HOME=/opt/bytesend-smtp git clone https://github.com/ByteSendApp/ByteSend.git . sudo -u smtp HOME=/opt/bytesend-smtp bash -lc "cd /opt/bytesend-smtp/apps/smtp-server && npm install && npm run build" # (Optional) Copy and configure .env file @@ -484,7 +484,7 @@ For high-volume deployments, consider: ## Support & Issues For bugs, feature requests, or questions: -- **GitHub Issues:** [github.com/NodeByteLTD/ByteSend/issues](https://github.com/NodeByteLTD/ByteSend/issues) +- **GitHub Issues:** [github.com/ByteSendApp/ByteSend/issues](https://github.com/ByteSendApp/ByteSend/issues) - **ByteSend Support:** [Contact us](https://bytesend.cloud/support) diff --git a/apps/smtp-server/README.md b/apps/smtp-server/README.md index c309385..f9a5828 100644 --- a/apps/smtp-server/README.md +++ b/apps/smtp-server/README.md @@ -2,7 +2,7 @@ A lightweight, production-ready SMTP server that forwards incoming email to the ByteSend API. Deploy it standalone or behind a reverse proxy to accept SMTP connections and integrate with ByteSend's email delivery platform. -[![GitHub](https://img.shields.io/badge/GitHub-ByteSend-181717?logo=github)](https://github.com/NodeByteLTD/ByteSend/tree/main/apps/smtp-server) +[![GitHub](https://img.shields.io/badge/GitHub-ByteSend-181717?logo=github)](https://github.com/ByteSendApp/ByteSend/tree/main/apps/smtp-server) [![License](https://img.shields.io/badge/License-AGPLv3-blue.svg)](LICENSE) [![Node.js](https://img.shields.io/badge/Node.js-18+-green)](https://nodejs.org) @@ -27,7 +27,7 @@ A lightweight, production-ready SMTP server that forwards incoming email to the ```bash # Clone the repository -git clone https://github.com/NodeByteLTD/ByteSend.git +git clone https://github.com/ByteSendApp/ByteSend.git cd ByteSend/apps/smtp-server # Configure docker-compose.yml @@ -44,7 +44,7 @@ docker compose logs -f smtp ```bash # Clone and install -git clone https://github.com/NodeByteLTD/ByteSend.git +git clone https://github.com/ByteSendApp/ByteSend.git cd ByteSend/apps/smtp-server npm install npm run build @@ -186,16 +186,16 @@ smtp.example.com:587 bytesend:your_api_key_here ## Deployment ### Docker Compose -See [docs/self-hosting/smtp-server.mdx](https://github.com/NodeByteLTD/ByteSend/blob/main/apps/docs/self-hosting/smtp-server.mdx#option-1-docker-recommended) +See [docs/self-hosting/smtp-server.mdx](https://github.com/ByteSendApp/ByteSend/blob/main/apps/docs/self-hosting/smtp-server.mdx#option-1-docker-recommended) ### Kubernetes See [contrib/k8s/deployment.yaml](contrib/k8s/deployment.yaml) ### Systemd -See [docs/self-hosting/smtp-server.mdx](https://github.com/NodeByteLTD/ByteSend/blob/main/apps/docs/self-hosting/smtp-server.mdx#systemd-service-setup) +See [docs/self-hosting/smtp-server.mdx](https://github.com/ByteSendApp/ByteSend/blob/main/apps/docs/self-hosting/smtp-server.mdx#systemd-service-setup) ### Nginx Reverse Proxy -See [docs/self-hosting/smtp-server.mdx](https://github.com/NodeByteLTD/ByteSend/blob/main/apps/docs/self-hosting/smtp-server.mdx#reverse-proxy-setup) +See [docs/self-hosting/smtp-server.mdx](https://github.com/ByteSendApp/ByteSend/blob/main/apps/docs/self-hosting/smtp-server.mdx#reverse-proxy-setup) --- @@ -272,8 +272,8 @@ See [CHANGELOG.md](CHANGELOG.md) for version history and release notes. ## Support - 📖 **Documentation:** [ByteSend Self-Hosting Guide](https://docs.bytesend.cloud/self-hosting/smtp-server) -- 🐛 **Issues:** [GitHub Issues](https://github.com/NodeByteLTD/ByteSend/issues) -- 💬 **Discussions:** [GitHub Discussions](https://github.com/NodeByteLTD/ByteSend/discussions) +- 🐛 **Issues:** [GitHub Issues](https://github.com/ByteSendApp/ByteSend/issues) +- 💬 **Discussions:** [GitHub Discussions](https://github.com/ByteSendApp/ByteSend/discussions) - 📧 **Email:** [support@bytesend.cloud](mailto:support@bytesend.cloud) --- diff --git a/apps/web/src/app/(marketing)/changelog/page.tsx b/apps/web/src/app/(marketing)/changelog/page.tsx index e633834..a2ee31e 100644 --- a/apps/web/src/app/(marketing)/changelog/page.tsx +++ b/apps/web/src/app/(marketing)/changelog/page.tsx @@ -30,7 +30,7 @@ type Release = { Data fetching: GitLab (custom instance) → GitHub (private) ───────────────────────────────────────────────────────────── */ -const GITHUB_REPO = "NodeByteLTD/ByteSend"; +const GITHUB_REPO = "ByteSendApp/ByteSend"; async function fetchFromGitLab(): Promise { const base = process.env.GITLAB_URL; diff --git a/apps/web/src/app/api/version/route.ts b/apps/web/src/app/api/version/route.ts index ba9f565..19a2821 100644 --- a/apps/web/src/app/api/version/route.ts +++ b/apps/web/src/app/api/version/route.ts @@ -2,7 +2,7 @@ import { NextResponse } from "next/server"; import { env } from "~/env"; import { logger } from "~/server/logger/log"; -const GITHUB_REPOS = ["NodeByteLTD/ByteSend"]; +const GITHUB_REPOS = ["ByteSendApp/ByteSend"]; const FALLBACK_VERSION = "canary"; const CACHE_TTL_MS = 10 * 60 * 1000; const FALLBACK_TTL_MS = 60 * 1000; diff --git a/apps/web/src/components/marketing/DevSection.tsx b/apps/web/src/components/marketing/DevSection.tsx index 47c11c0..75293d1 100644 --- a/apps/web/src/components/marketing/DevSection.tsx +++ b/apps/web/src/components/marketing/DevSection.tsx @@ -49,7 +49,7 @@ import ( "context" "log" - bytesend "github.com/nodebyteltd/bytesend-go" + bytesend "github.com/ByteSendApp/ByteSend/packages/go-sdk" ) func main() { diff --git a/apps/web/src/components/marketing/SiteFooter.tsx b/apps/web/src/components/marketing/SiteFooter.tsx index c8ce6d8..31b9464 100644 --- a/apps/web/src/components/marketing/SiteFooter.tsx +++ b/apps/web/src/components/marketing/SiteFooter.tsx @@ -28,7 +28,7 @@ export function SiteFooter() { {/* Right: social icons */}
- + diff --git a/apps/web/src/env.js b/apps/web/src/env.js index 6ee0cde..4f920a8 100644 --- a/apps/web/src/env.js +++ b/apps/web/src/env.js @@ -56,6 +56,7 @@ export const env = createEnv({ S3_COMPATIBLE_API_URL: z.string().optional(), S3_COMPATIBLE_PUBLIC_URL: z.string().optional(), S3_COMPATIBLE_BUCKET: z.string().optional(), + S3_COMPATIBLE_REGION: z.string().default("auto"), STRIPE_SECRET_KEY: z.string().optional(), STRIPE_WEBHOOK_SECRET: z.string().optional(), SMTP_HOST: z.string().default("smtp.bytesend.cloud"), @@ -115,6 +116,7 @@ export const env = createEnv({ S3_COMPATIBLE_API_URL: process.env.S3_COMPATIBLE_API_URL, S3_COMPATIBLE_PUBLIC_URL: process.env.S3_COMPATIBLE_PUBLIC_URL, S3_COMPATIBLE_BUCKET: process.env.S3_COMPATIBLE_BUCKET, + S3_COMPATIBLE_REGION: process.env.S3_COMPATIBLE_REGION, STRIPE_SECRET_KEY: process.env.STRIPE_SECRET_KEY, STRIPE_WEBHOOK_SECRET: process.env.STRIPE_WEBHOOK_SECRET, SMTP_HOST: process.env.SMTP_HOST, diff --git a/apps/web/src/server/service/storage-service.ts b/apps/web/src/server/service/storage-service.ts index 244bf12..f542e5f 100644 --- a/apps/web/src/server/service/storage-service.ts +++ b/apps/web/src/server/service/storage-service.ts @@ -23,7 +23,7 @@ const getClient = () => { env.S3_COMPATIBLE_SECRET_KEY ) { S3 = new S3Client({ - region: "auto", + region: env.S3_COMPATIBLE_REGION, endpoint: env.S3_COMPATIBLE_API_URL, credentials: { accessKeyId: env.S3_COMPATIBLE_ACCESS_KEY, diff --git a/apps/web/src/server/storage/s3.ts b/apps/web/src/server/storage/s3.ts index cdf7516..9acc366 100644 --- a/apps/web/src/server/storage/s3.ts +++ b/apps/web/src/server/storage/s3.ts @@ -14,7 +14,7 @@ function getS3Client(): S3Client | null { return new S3Client({ endpoint: env.S3_COMPATIBLE_API_URL, - region: "auto", + region: env.S3_COMPATIBLE_REGION, credentials: { accessKeyId: env.S3_COMPATIBLE_ACCESS_KEY, secretAccessKey: env.S3_COMPATIBLE_SECRET_KEY, diff --git a/docker/cloud/docker-compose.web.yml b/docker/cloud/docker-compose.web.yml index d481103..79ca05b 100644 --- a/docker/cloud/docker-compose.web.yml +++ b/docker/cloud/docker-compose.web.yml @@ -79,6 +79,7 @@ services: - S3_COMPATIBLE_API_URL=${S3_COMPATIBLE_API_URL} - S3_COMPATIBLE_PUBLIC_URL=${S3_COMPATIBLE_PUBLIC_URL} - S3_COMPATIBLE_BUCKET=${S3_COMPATIBLE_BUCKET} + - S3_COMPATIBLE_REGION=${S3_COMPATIBLE_REGION:-auto} # API Keys - BYTESEND_API_KEY=${BYTESEND_API_KEY} diff --git a/docker/prod/compose.yml b/docker/prod/compose.yml index 5075560..399b916 100644 --- a/docker/prod/compose.yml +++ b/docker/prod/compose.yml @@ -84,6 +84,7 @@ services: - S3_COMPATIBLE_API_URL=${S3_COMPATIBLE_API_URL:-http://minio:9002} - S3_COMPATIBLE_PUBLIC_URL=${S3_COMPATIBLE_PUBLIC_URL:-http://localhost:9002/bytesend} - S3_COMPATIBLE_BUCKET=${S3_COMPATIBLE_BUCKET:-bytesend} + - S3_COMPATIBLE_REGION=${S3_COMPATIBLE_REGION:-auto} # ── Rate limiting ──────────────────────────────────────────────────────── - API_RATE_LIMIT=${API_RATE_LIMIT:-1} diff --git a/packages/go-sdk/README.md b/packages/go-sdk/README.md index 2a133f7..2795138 100644 --- a/packages/go-sdk/README.md +++ b/packages/go-sdk/README.md @@ -19,7 +19,7 @@ The official Go SDK for [ByteSend](https://bytesend.cloud): a transactional emai ## Installation ```sh -go get github.com/nodebyteltd/bytesend-go +go get github.com/ByteSendApp/ByteSend/packages/go-sdk ``` Requires Go 1.21+. @@ -34,7 +34,7 @@ import ( "fmt" "log" - bytesend "github.com/nodebyteltd/bytesend-go" + bytesend "github.com/ByteSendApp/ByteSend/packages/go-sdk" ) func main() { diff --git a/packages/go-sdk/client.go b/packages/go-sdk/client.go index ac61213..2028ee1 100644 --- a/packages/go-sdk/client.go +++ b/packages/go-sdk/client.go @@ -13,7 +13,7 @@ import ( ) const defaultBaseURL = "https://bytesend.cloud/api/v1" -const userAgent = "bytesend-go/0.3.2" +const userAgent = "bytesend-go/0.3.3" const maxResponseBodyBytes int64 = 10 * 1024 * 1024 // 10 MB type Client struct { @@ -124,7 +124,13 @@ func (c *Client) doRequest(ctx context.Context, method, path string, body any, v } errResp := &ErrorResponse{Message: resp.Status, Code: "INTERNAL_SERVER_ERROR"} - _ = json.NewDecoder(limited).Decode(errResp) + var envelope struct { + Error *ErrorResponse `json:"error"` + } + if err := json.NewDecoder(limited).Decode(&envelope); err == nil && envelope.Error != nil && envelope.Error.Code != "" { + errResp = envelope.Error + } + errResp.StatusCode = resp.StatusCode return errResp } diff --git a/packages/go-sdk/go.mod b/packages/go-sdk/go.mod index 3f9e885..37cdf24 100644 --- a/packages/go-sdk/go.mod +++ b/packages/go-sdk/go.mod @@ -1,3 +1,3 @@ -module github.com/nodebyteltd/bytesend-go +module github.com/ByteSendApp/ByteSend/packages/go-sdk go 1.21 diff --git a/packages/go-sdk/types.go b/packages/go-sdk/types.go index ddb42c4..2541885 100644 --- a/packages/go-sdk/types.go +++ b/packages/go-sdk/types.go @@ -6,8 +6,9 @@ import ( ) type ErrorResponse struct { - Message string `json:"message"` - Code string `json:"code"` + Message string `json:"message"` + Code string `json:"code"` + StatusCode int `json:"-"` } func (e *ErrorResponse) Error() string { diff --git a/packages/python-sdk/README.md b/packages/python-sdk/README.md index d67f5cc..3bfddbe 100644 --- a/packages/python-sdk/README.md +++ b/packages/python-sdk/README.md @@ -103,7 +103,7 @@ It is published as `bytesend` on PyPI. - **ContactBooks**: `client.contact_books.list()`, `client.contact_books.create()`, `client.contact_books.get()`, `client.contact_books.update()` - **Contacts**: `client.contacts.create()`, `client.contacts.list()`, `client.contacts.get()`, `client.contacts.bulk_create()`, `client.contacts.bulk_delete()` - **Domains**: `client.domains.create()`, `client.domains.get()`, `client.domains.verify()` -- **Campaigns**: `client.campaigns.create()`, `client.campaigns.get()`, `client.campaigns.schedule()`, `client.campaigns.pause()`, `client.campaigns.resume()` +- **Campaigns**: `client.campaigns.create()`, `client.campaigns.get()`, `client.campaigns.schedule()`, `client.campaigns.pause()`, `client.campaigns.resume()`, `client.campaigns.delete()` Notes diff --git a/packages/python-sdk/bytesend/campaigns.py b/packages/python-sdk/bytesend/campaigns.py index bd08e09..6646475 100644 --- a/packages/python-sdk/bytesend/campaigns.py +++ b/packages/python-sdk/bytesend/campaigns.py @@ -64,5 +64,11 @@ def resume( ) return (data, err) # type: ignore[return-value] + def delete( + self, campaign_id: str + ) -> Tuple[Optional[Campaign], Optional[APIError]]: + data, err = self.bytesend.delete(f"/campaigns/{campaign_id}") + return (data, err) # type: ignore[return-value] + from .bytesend import ByteSend # noqa: E402 pylint: disable=wrong-import-position \ No newline at end of file diff --git a/packages/python-sdk/pyproject.toml b/packages/python-sdk/pyproject.toml index 0f386d2..b279382 100644 --- a/packages/python-sdk/pyproject.toml +++ b/packages/python-sdk/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "bytesend" -version = "0.1.2" +version = "0.1.3" description = "Python SDK for the ByteSend API" authors = ["NodeByte LTD"] license = "AGPL-3.0" diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 193ecf3..61eceaa 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -5,7 +5,7 @@ "license": "AGPL-3.0-only", "repository": { "type": "git", - "url": "https://github.com/NodeByteLTD/ByteSend" + "url": "https://github.com/ByteSendApp/ByteSend" }, "main": "./dist/index.js", "module": "./dist/index.mjs",