← Back to docs

HTTP Clients

HTTP Clients

Postscale is a JSON REST API. Use curl, fetch, your language's standard HTTP client, or any mature HTTP library.

Official SDK packages are not published yet. When they are available, this page will list install commands and versioning details. Until then, the REST API is the supported integration surface.

The public OpenAPI 3.0 specification is available at /openapi.yaml if you want to generate a typed client or import the API into Postman, Insomnia, or similar tooling.

Send with curl

curl -X POST https://api.postscale.io/v1/send \
  -H "Authorization: Bearer ps_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "from": "hello@yourapp.com",
    "to": ["user@example.com"],
    "subject": "Welcome!",
    "html_body": "<h1>Hello World</h1>"
  }'

Send with fetch

const response = await fetch("https://api.postscale.io/v1/send", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.POSTSCALE_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    from: "hello@yourapp.com",
    to: ["user@example.com"],
    subject: "Welcome!",
    html_body: "<h1>Hello World</h1>",
  }),
});

if (!response.ok) {
  throw new Error(`Postscale send failed: ${response.status}`);
}

const result = await response.json();
console.log("Email sent:", result.message_id);

Python example

import os
import requests

response = requests.post(
    "https://api.postscale.io/v1/send",
    headers={
        "Authorization": f"Bearer {os.environ['POSTSCALE_API_KEY']}",
        "Content-Type": "application/json",
    },
    json={
        "from": "hello@yourapp.com",
        "to": ["user@example.com"],
        "subject": "Welcome!",
        "html_body": "<h1>Hello World</h1>",
    },
    timeout=30,
)
response.raise_for_status()
print("Email sent:", response.json()["message_id"])

Go example

package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"net/http"
	"os"
	"time"
)

func main() {
	body, _ := json.Marshal(map[string]any{
		"from":      "hello@yourapp.com",
		"to":        []string{"user@example.com"},
		"subject":   "Welcome!",
		"html_body": "<h1>Hello World</h1>",
	})

	req, _ := http.NewRequest("POST", "https://api.postscale.io/v1/send", bytes.NewReader(body))
	req.Header.Set("Authorization", "Bearer "+os.Getenv("POSTSCALE_API_KEY"))
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{Timeout: 30 * time.Second}
	resp, err := client.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	if resp.StatusCode >= 300 {
		panic(fmt.Sprintf("Postscale send failed: %s", resp.Status))
	}
}

Client configuration

Use these defaults when building your own wrapper:

OptionRecommendation
Base URLhttps://api.postscale.io
AuthenticationAuthorization: Bearer <api_key>
Content typeapplication/json
Timeout30 seconds
RetriesRetry transient 429 and 5xx responses with exponential backoff

Webhooks

Webhook signature verification uses standard HMAC code and does not require an SDK. See the Webhooks guide for runnable Node and Python verifiers, plus details on the timestamped t=...,v1=... format and secret rotation.