# Install and configure an SDK

> Install the pushq SDK for TypeScript, Python, Go, Java or .NET, create a client, and handle errors, pagination and webhook signatures.

Source: https://pushqueue.dev/docs/getting-started/sdks/

pushq has official SDKs for TypeScript/JavaScript, Python, Go, Java and .NET. Each one is a thin, typed wrapper over the [REST API](https://pushqueue.dev/docs/reference/api/). They cover every queue and task endpoint and include a helper to verify signed deliveries. This page covers what is the same everywhere: installing, creating a client, client options, errors, pagination and signature verification. The rest of the docs show every example in all five languages, plus `curl`.

Parameter tables across the docs use the API's JSON field names, such as `rate_limits.max_dispatches_per_second`. Each SDK uses its own language's casing for those names. See [Naming conventions](#naming-conventions).

## Install


**TypeScript**

```bash
npm install pushq
```

**Python**

```bash
pip install pushq
```

**Go**

```bash
go get github.com/blissfulrays/pushq/sdks/go
```

**Java**

```bash
git clone https://github.com/blissfulrays/pushq.git
cd pushq/sdks/java
mvn install -DskipTests
```

**.NET**

```bash
dotnet add package Pushq
```

- **TypeScript:** `pnpm add pushq` and `bun add pushq` work too. In Deno, import `npm:pushq`.
- **Go:** the import path ends in `/go`, so import the package with an explicit name: `import pushq "github.com/blissfulrays/pushq/sdks/go"`.
- **Java:** the SDK is not on Maven Central yet; that is coming. Until then, `mvn install` builds it and puts it in your local Maven repository (`~/.m2`). Then add the dependency:


**Maven**

```xml
<dependency>
  <groupId>io.github.blissfulrays</groupId>
  <artifactId>pushq</artifactId>
  <version>1.0.0-SNAPSHOT</version>
</dependency>
```

**Gradle**

```kotlin
repositories {
    mavenLocal()   // needed until the SDK is on Maven Central
    mavenCentral()
}

dependencies {
    implementation("io.github.blissfulrays:pushq:1.0.0-SNAPSHOT")
}
```

The Maven group is `io.github.blissfulrays`, but the Java package is `io.pushq`.

## Create a client

### Hosted API

Create an API key in the [console](https://console.pushqueue.dev/) (see [API keys](https://pushqueue.dev/docs/guides/api-keys/)) and pass it to the client. With no base URL, every SDK talks to the hosted API at `https://api.pushqueue.dev`.


**TypeScript**

```ts

const pq = new Pushq({ apiKey: process.env.PUSHQ_API_KEY });
```

**Python**

```python
import os
from pushq import Pushq

pq = Pushq(api_key=os.environ["PUSHQ_API_KEY"])
```

**Go**

```go
import (
	"context"
	"os"

	pushq "github.com/blissfulrays/pushq/sdks/go"
)

pq := pushq.New("", os.Getenv("PUSHQ_API_KEY")) // "" = https://api.pushqueue.dev
ctx := context.Background()
```

**Java**

```java
import io.pushq.*;

Pushq pq = Pushq.builder()
    .apiKey(System.getenv("PUSHQ_API_KEY"))
    .build();
```

**.NET**

```csharp
using Pushq;

using var pq = new PushqClient(apiKey: Environment.GetEnvironmentVariable("PUSHQ_API_KEY"));
```

**curl**

```bash
curl https://api.pushqueue.dev/v1/queues/emails \
  -H "Authorization: Bearer $PUSHQ_API_KEY"
```

The SDKs send the key as `Authorization: Bearer <key>`. None of them reads environment variables on its own, so pass the key in explicitly. Every SDK exports the default URL as a constant: `DEFAULT_BASE_URL` in TypeScript and Python, `pushq.DefaultBaseURL` in Go, `Pushq.DEFAULT_BASE_URL` in Java and `PushqClient.DefaultBaseUrl` in .NET.

Create one client and reuse it. The Go, Java and .NET clients are documented as safe to share across threads and goroutines.

### Self-hosted server

Pass your server's URL. If you run [`pushq dev`](https://pushqueue.dev/docs/getting-started/local-development/) locally, which has no API keys, leave the key out. Every SDK then sends no `Authorization` header.


**TypeScript**

```ts

const pq = new Pushq({ baseUrl: "https://pushq.internal.example.com", apiKey: process.env.PUSHQ_API_KEY });

// `pushq dev`: no key needed
const local = new Pushq({ baseUrl: "http://localhost:8080" });
```

**Python**

```python
import os
from pushq import Pushq

pq = Pushq("https://pushq.internal.example.com", api_key=os.environ["PUSHQ_API_KEY"])

# `pushq dev`: no key needed
local = Pushq("http://localhost:8080")
```

**Go**

```go
pq := pushq.New("https://pushq.internal.example.com", os.Getenv("PUSHQ_API_KEY"))

// `pushq dev`: pass an empty key
local := pushq.New("http://localhost:8080", "")
```

**Java**

```java
Pushq pq = Pushq.builder()
    .baseUrl("https://pushq.internal.example.com")
    .apiKey(System.getenv("PUSHQ_API_KEY"))
    .build();

// `pushq dev`: no key needed
Pushq local = Pushq.builder().baseUrl("http://localhost:8080").build();
```

**.NET**

```csharp
using Pushq;

using var pq = new PushqClient("https://pushq.internal.example.com",
    apiKey: Environment.GetEnvironmentVariable("PUSHQ_API_KEY"));

// `pushq dev`: no key needed
using var local = new PushqClient("http://localhost:8080");
```

**curl**

```bash
curl http://localhost:8080/v1/queues/emails
```

Every SDK strips trailing slashes from the base URL. An empty or whitespace-only base URL falls back to the hosted API.

## Client options

Apart from the base URL and API key, the SDKs let you set a request timeout and, in most of them, supply your own HTTP client:


**TypeScript**

```ts

const pq = new Pushq({
  baseUrl: "https://api.pushqueue.dev",
  apiKey: process.env.PUSHQ_API_KEY,
  timeoutMs: 10_000, // per request; default 30_000
  fetch: async (input, init) => {
    // custom fetch: logging, tracing, proxies, tests
    const res = await fetch(input, init);
    console.log(init?.method, String(input), res.status);
    return res;
  },
});
```

**Python**

```python
import httpx
from pushq import Pushq

# timeout in seconds, default 30.0
pq = Pushq("https://api.pushqueue.dev", api_key="pq_...", timeout=10.0)

# or bring your own httpx.Client (proxies, TLS, transport retries, event hooks)
http = httpx.Client(
    base_url="https://api.pushqueue.dev",
    headers={"Authorization": "Bearer pq_..."},
    timeout=10.0,
    transport=httpx.HTTPTransport(retries=2),
)
pq = Pushq(client=http)

# close the connection pool when done, or use a with-block
pq.close()
with Pushq(api_key="pq_...") as pq:
    pq.get_queue("emails")
```

**Go**

```go
hc := &http.Client{
	Timeout:   10 * time.Second,
	Transport: &http.Transport{MaxIdleConnsPerHost: 50},
}
pq := pushq.New("", os.Getenv("PUSHQ_API_KEY"), pushq.WithHTTPClient(hc))
```

**Java**

```java
import java.time.Duration;

Pushq pq = Pushq.builder()
    .baseUrl("https://api.pushqueue.dev")
    .apiKey(System.getenv("PUSHQ_API_KEY"))
    .timeout(Duration.ofSeconds(10))   // default 30s; connect and per-request timeout
    .build();
```

**.NET**

```csharp
using Pushq;

// Standalone, with a custom timeout
using var pq = new PushqClient(new PushqClientOptions
{
    BaseUrl = "https://api.pushqueue.dev",
    ApiKey = Environment.GetEnvironmentVariable("PUSHQ_API_KEY"),
    Timeout = TimeSpan.FromSeconds(10),   // default 30s; ignored when HttpClient is set
});

// ASP.NET Core with IHttpClientFactory
builder.Services.AddHttpClient("pushq", http => http.Timeout = TimeSpan.FromSeconds(15));
builder.Services.AddSingleton(sp => new PushqClient(new PushqClientOptions
{
    BaseUrl = builder.Configuration["Pushq:Url"] ?? PushqClient.DefaultBaseUrl,
    ApiKey = builder.Configuration["Pushq:ApiKey"],
    HttpClient = sp.GetRequiredService<IHttpClientFactory>().CreateClient("pushq"),
}));
```

| SDK | Timeout | Custom HTTP client | Notes |
| --- | --- | --- | --- |
| TypeScript | `timeoutMs`, default `30000` | `fetch` (defaults to the global `fetch`) | The constructor throws if no `fetch` is available. |
| Python | `timeout` (seconds), default `30.0` | `client=httpx.Client(...)`, or `httpx.AsyncClient` for `AsyncPushq` | When you pass `client`, the SDK ignores `base_url`, `api_key` and `timeout`; set them on the httpx client. `close()` also closes a client you passed in. |
| Go | from the `http.Client`, default 30 s | `pushq.WithHTTPClient(hc)` | This replaces the whole client. Per-call deadlines come from the `context.Context` that every method takes first. |
| Java | `timeout(Duration)`, default 30 s | not supported | The SDK uses its own `java.net.http.HttpClient` and does not follow redirects. |
| .NET | `Timeout`, default 30 s | `HttpClient` | `Timeout` is ignored when you supply `HttpClient`. The SDK never disposes an `HttpClient` you supply. Every method takes an optional `CancellationToken`. |

None of the SDKs retries failed API calls. If you add retries, set a `task_id` on every task you create. A retried create then fails with `already_exists` instead of enqueueing the task twice.

## Naming conventions

The SDKs follow their language's conventions, so the same call looks different in each:

| | TypeScript | Python | Go | Java | .NET |
| --- | --- | --- | --- | --- | --- |
| Create a task | `createTask` | `create_task` | `CreateTask` | `createTask` | `CreateTaskAsync` |
| Batch create | `createTasks` | `create_tasks` | `CreateTasks` | `createTasks` | `CreateTasksAsync` |
| Queue stats | `queueStats` | `queue_stats` | `QueueStats` | `queueStats` | `GetQueueStatsAsync` |
| Fields | camelCase (`maxDispatchesPerSecond`) | snake_case (`max_dispatches_per_second`) | PascalCase (`MaxDispatchesPerSecond`) | camelCase builder methods and getters | PascalCase properties |
| Building input | object literals | keyword arguments and config classes (`RateLimits`, `Retry`, `Target`) | structs; optional numbers are pointers (`pushq.Int(3)`, `pushq.Float64(3600)`) | builders (`TaskCreate.builder()...build()`) | object initializers |
| Sync or async | all methods return a `Promise` | `Pushq` (sync) and `AsyncPushq` (async) | blocking; `ctx` first | synchronous | `...Async` methods |
| Timestamps | `Date` | `datetime` | `time.Time` | `Instant` | `DateTimeOffset` |
| Raw body (`body_base64`) | `body: string \| Uint8Array` | `body: bytes` | `Body []byte` | `body(byte[])` | `Body` (`byte[]`) |
| Delay and deadline | seconds (`delaySeconds`) | seconds | seconds (`*float64`) | seconds | `TimeSpan` (`Delay`, `DispatchDeadline`) |
| Task type | `Task` | `Task` | `pushq.Task` | `Task` | `PushqTask` |

Every SDK base64-encodes raw bodies for you, so you never build `body_base64` yourself. Queue names that contain `/`, such as `user/instagram`, are URL-encoded automatically. See [queue folders](https://pushqueue.dev/docs/concepts/queues/).

## Error handling

Every non-2xx API response becomes an error that carries the HTTP status, a stable machine-readable `code`, and a human-readable `detail`. Branch on `code`, not on the message text.


**TypeScript**

```ts

try {
  await pq.createTask("emails", { taskId: "welcome-user-42", path: "/hooks/send-welcome" });
} catch (err) {
  if (err instanceof PushqError && err.code === "already_exists") {
    // already enqueued: nothing to do
  } else if (err instanceof PushqError) {
    console.error(err.status, err.code, err.detail);
    throw err;
  } else {
    throw err; // timeout or network error
  }
}
```

**Python**

```python
from pushq import PushqError

try:
    pq.create_task("emails", path="/hooks/send-welcome", task_id="welcome-user-42")
except PushqError as e:
    if e.code == "already_exists":
        pass  # already enqueued: nothing to do
    else:
        print(e.status, e.code, e.detail)
        raise
```

**Go**

```go
_, err := pq.CreateTask(ctx, "emails", pushq.TaskCreate{
	TaskID: "welcome-user-42",
	Path:   "/hooks/send-welcome",
})
if pushq.IsCode(err, "already_exists") {
	// already enqueued: nothing to do
} else if err != nil {
	var pe *pushq.Error
	if errors.As(err, &pe) {
		log.Printf("pushq %d %s: %s", pe.Status, pe.Code, pe.Detail)
	}
	return err
}
```

**Java**

```java
try {
    pq.createTask("emails", TaskCreate.builder()
        .taskId("welcome-user-42")
        .path("/hooks/send-welcome")
        .build());
} catch (PushqException e) {
    if ("already_exists".equals(e.getCode())) {
        // already enqueued: nothing to do
    } else {
        System.err.println(e.getStatus() + " " + e.getCode() + ": " + e.getDetail());
        throw e;
    }
}
```

**.NET**

```csharp
try
{
    await pq.CreateTaskAsync("emails", new TaskCreate { TaskId = "welcome-user-42", Path = "/hooks/send-welcome" });
}
catch (PushqException e) when (e.Code == "already_exists")
{
    // already enqueued: nothing to do
}
catch (PushqException e)
{
    Console.WriteLine($"{e.Status} {e.Code}: {e.Detail}");
    throw;
}
```

**curl**

```bash
curl -i -X POST https://api.pushqueue.dev/v1/queues/emails/tasks \
  -H "Authorization: Bearer $PUSHQ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"task_id":"welcome-user-42","path":"/hooks/send-welcome"}'
```

Over raw HTTP, errors come back as [RFC 9457](https://www.rfc-editor.org/rfc/rfc9457) `application/problem+json`, and the SDKs read the same fields:

```json
{
  "type": "about:blank",
  "title": "Conflict",
  "status": 409,
  "code": "already_exists",
  "detail": "...",
  "instance": "/v1/queues/emails/tasks"
}
```

The [error reference](https://pushqueue.dev/docs/reference/errors/) lists every code, its HTTP status and what to do about it.

API errors and transport failures (timeouts, refused connections, DNS) surface differently:

| SDK | API error | Transport failure | Invalid input caught before sending |
| --- | --- | --- | --- |
| TypeScript | `PushqError` (`status`, `code`, `detail`) | `DOMException` named `TimeoutError` on timeout; otherwise what `fetch` throws (`TypeError`) | `Error` when both `body` and `jsonBody` are set |
| Python | `PushqError` (`status`, `code`, `detail`) | httpx exceptions, such as `httpx.TimeoutException` and `httpx.ConnectError` | `ValueError` when both `body` and `json_body` are set |
| Go | `*pushq.Error` (`Status`, `Code`, `Detail`); test with `pushq.IsCode(err, code)` | the `net/http` or `context` error, unwrapped | none |
| Java | unchecked `PushqException` (`getStatus()`, `getCode()`, `getDetail()`) | `PushqException` with `getStatus() == 0`; the cause holds the `IOException` | `IllegalStateException` from `TaskCreate.build()` for conflicting fields |
| .NET | `PushqException` (`Status`, `Code`, `Detail`) | `HttpRequestException` or `TaskCanceledException` | `ArgumentException` for conflicting fields |

If an error response is not a problem document, for example an HTML page from a proxy, the code is `internal` in TypeScript, Python, Go and .NET. In Java it is `null`. In every SDK, `detail` holds the response body, which may be truncated.

## Pagination

`list queues` and `list tasks` return one page at a time with a `next_page_token`. Pass it back as `page_token` to get the next page, and keep the other parameters the same. The last page has no token. Page size defaults to 100 and is capped at 1000. None of the SDKs has an auto-paging iterator, so loop until the token is empty:


**TypeScript**

```ts
let pageToken: string | undefined;
do {
  const page = await pq.listTasks("emails", { state: "failed", pageSize: 1000, pageToken });
  for (const task of page.items) console.log(task.id);
  pageToken = page.nextPageToken;
} while (pageToken);
```

**Python**

```python
token = None
while True:
    page = pq.list_tasks("emails", state="failed", page_size=1000, page_token=token)
    for task in page.items:
        print(task.id)
    token = page.next_page_token
    if token is None:
        break
```

**Go**

```go
token := ""
for {
	tasks, next, err := pq.ListTasks(ctx, "emails", pushq.ListTasksParams{
		State:     "failed",
		PageSize:  1000,
		PageToken: token,
	})
	if err != nil {
		return err
	}
	for _, t := range tasks {
		fmt.Println(t.ID)
	}
	if next == "" {
		break
	}
	token = next
}
```

**Java**

```java
String token = null;
do {
    ListTasksParams.Builder p = ListTasksParams.builder().state("failed").pageSize(1000);
    if (token != null) p.pageToken(token);
    TaskPage page = pq.listTasks("emails", p.build());
    for (Task t : page.getTasks()) System.out.println(t.getId());
    token = page.getNextPageToken();
} while (token != null && !token.isEmpty());
```

**.NET**

```csharp
string? token = null;
do
{
    var page = await pq.ListTasksAsync("emails", new ListTasksOptions
    {
        State = TaskState.Failed,
        PageSize = 1000,
        PageToken = token,
    });
    foreach (var t in page.Items)
        Console.WriteLine(t.Id);
    token = page.NextPageToken;
} while (token != null);
```

**curl**

```bash
curl "https://api.pushqueue.dev/v1/queues/emails/tasks?state=failed&page_size=1000" \
  -H "Authorization: Bearer $PUSHQ_API_KEY"

# Next page: pass next_page_token from the previous response
curl "https://api.pushqueue.dev/v1/queues/emails/tasks?state=failed&page_size=1000&page_token=MTIzNA" \
  -H "Authorization: Bearer $PUSHQ_API_KEY"
```

Task lists are returned newest first, and queue lists in name order. Listing queues needs an admin API key.

## Verify signatures

When a queue has a `target.signing_secret`, pushq signs every delivery using the [Standard Webhooks](https://www.standardwebhooks.com) scheme, with `webhook-id`, `webhook-timestamp` and `webhook-signature` headers. Each SDK ships a verifier. Use it in the endpoint that receives tasks, and reject the request with `401` if verification fails. [Delivery](https://pushqueue.dev/docs/concepts/delivery/) explains the headers and the signing scheme.

Always verify the raw request body, exactly as it arrived. If a framework parses the JSON first and you re-serialize it, the bytes can differ and verification fails.


**TypeScript**

```ts

const app = express();

// express.raw keeps the body as an unparsed Buffer; don't run express.json() on this route.
app.post("/hooks/send-welcome", express.raw({ type: "*/*" }), async (req, res) => {
  const payload: Buffer = Buffer.isBuffer(req.body) ? req.body : Buffer.alloc(0);
  let webhookId: string;
  try {
    webhookId = await verifySignature({
      secret: process.env.PUSHQ_SIGNING_SECRET!,
      headers: req.headers,
      payload,
    });
  } catch (err) {
    if (err instanceof WebhookVerificationError) return res.sendStatus(401);
    throw err;
  }
  const { userId } = JSON.parse(payload.toString("utf8"));
  // ... do the work, using webhookId as an idempotency key ...
  res.sendStatus(204);
});
```

**Python**

```python
import os
from fastapi import FastAPI, HTTPException, Request
from pushq import WebhookVerificationError, verify_signature

SECRET = os.environ["PUSHQ_SIGNING_SECRET"]
app = FastAPI()

@app.post("/hooks/send-welcome")
async def send_welcome(request: Request):
    body = await request.body()  # raw bytes, not parsed JSON
    try:
        webhook_id = verify_signature(SECRET, request.headers, body)
    except WebhookVerificationError:
        raise HTTPException(status_code=401)
    # ... do the work, using webhook_id as an idempotency key ...
    return {"ok": True}
```

**Go**

```go
var secret = os.Getenv("PUSHQ_SIGNING_SECRET")

func handleSendWelcome(w http.ResponseWriter, r *http.Request) {
	body, err := io.ReadAll(r.Body) // raw bytes, before any JSON decoding
	if err != nil {
		http.Error(w, "read error", http.StatusBadRequest)
		return
	}
	webhookID, err := pushq.VerifySignature(secret, r.Header, body, 5*time.Minute)
	if err != nil {
		http.Error(w, "invalid signature", http.StatusUnauthorized)
		return
	}
	_ = webhookID // ... json.Unmarshal(body, &payload), do the work, dedupe on webhookID ...
	w.WriteHeader(http.StatusNoContent)
}

// http.HandleFunc("POST /hooks/send-welcome", handleSendWelcome)
```

**Java**

```java
import io.pushq.WebhookVerificationException;
import io.pushq.Webhooks;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
public class PushqHooks {
    private final String secret = System.getenv("PUSHQ_SIGNING_SECRET");

    @PostMapping("/hooks/send-welcome")
    public ResponseEntity<Void> sendWelcome(@RequestBody byte[] payload,   // raw body, unparsed
                                            @RequestHeader("webhook-id") String id,
                                            @RequestHeader("webhook-timestamp") long ts,
                                            @RequestHeader("webhook-signature") String sig) {
        try {
            Webhooks.verifySignature(secret, id, ts, payload, sig, 300);
        } catch (WebhookVerificationException e) {
            return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();
        }
        // ... parse payload and do the work, using id as an idempotency key ...
        return ResponseEntity.noContent().build();
    }
}
```

**.NET**

```csharp
using Pushq;

var signingSecret = builder.Configuration["Pushq:SigningSecret"]!;

app.MapPost("/hooks/send-welcome", async (HttpRequest req) =>
{
    using var ms = new MemoryStream();
    await req.Body.CopyToAsync(ms);
    var body = ms.ToArray();
    try
    {
        string webhookId = Webhooks.VerifySignature(signingSecret, name => req.Headers[name].FirstOrDefault(), body);
        // ... deserialize body and do the work, using webhookId as an idempotency key ...
        return Results.NoContent();
    }
    catch (WebhookVerificationException)
    {
        return Results.Unauthorized();
    }
});
```

The `webhook-id` has the form `<queue>/<task_id>`, for example `emails/welcome-user-42`, and stays the same on every retry of a task. Use it as an idempotency key to skip work you have already done. Respond with a 2xx status once the work succeeds. Any other status, or no response before the dispatch deadline, counts as a failed attempt and is [retried](https://pushqueue.dev/docs/concepts/retries/).

Other frameworks:

- **TypeScript (Fetch API runtimes: Hono, Cloudflare Workers, Next.js route handlers, Deno, Bun):** pass `payload: new Uint8Array(await request.arrayBuffer())` and `headers: request.headers`. In Hono, use `c.req.raw.headers`.
- **Python:** in Flask, pass `request.headers, request.get_data()`. In Django, pass `request.headers, request.body` in a `@csrf_exempt` view.
- **Go:** chi handlers are plain `http.HandlerFunc`s and work unchanged. In gin, read `c.GetRawData()` and `c.Request.Header` before any `ShouldBindJSON`.
- **Java (plain Servlet):** read `req.getInputStream().readAllBytes()` and the three headers with `req.getHeader(...)`.
- **.NET (MVC controllers):** read `Request.Body` the same way, and don't declare a `[FromBody]` parameter.

### Calling the verifier directly

Here is each verifier with all of its arguments, including the timestamp tolerance:


**TypeScript**

```ts

const webhookId: string = await verifySignature({
  secret: "whsec_dGVzdC1zZWNyZXQ=",  // "whsec_<base64>" or a raw string
  headers: request.headers,          // Headers or a plain object
  payload: rawBody,                  // string | Uint8Array, exactly as received
  toleranceSeconds: 300,             // default 300; 0 disables the timestamp check
  now: new Date(),                   // optional, for tests
});
```

**Python**

```python
import time
from pushq import verify_signature

webhook_id = verify_signature(
    "whsec_dGVzdC1zZWNyZXQ=",  # "whsec_<base64>" or a raw string
    headers,                    # any mapping with the webhook-* headers
    raw_body,                   # bytes or str
    tolerance_seconds=300,      # default 300; <= 0 disables the timestamp check
    now=time.time(),            # optional, unix seconds, for tests
)
```

**Go**

```go
webhookID, err := pushq.VerifySignature(
	"whsec_dGVzdC1zZWNyZXQ=", // "whsec_<base64>" or a raw string
	r.Header,                 // http.Header
	body,                     // []byte, exactly as received
	5*time.Minute,            // tolerance; <= 0 disables the timestamp check
)
if errors.Is(err, pushq.ErrVerification) {
	// reject with 401
}
```

**Java**

```java
Webhooks.verifySignature(
    "whsec_dGVzdC1zZWNyZXQ=", // "whsec_<base64>" or a raw string
    msgId,                    // webhook-id header
    timestampSecs,            // webhook-timestamp header, as a long
    rawBody,                  // byte[], exactly as received
    signatureHeader,          // webhook-signature header
    300);                     // tolerance in seconds

// Overload with an injectable java.time.Clock, for tests:
Webhooks.verifySignature(secret, msgId, timestampSecs, rawBody, signatureHeader, 300, clock);
```

**.NET**

```csharp
string webhookId = Webhooks.VerifySignature(
    secret: "whsec_dGVzdC1zZWNyZXQ=",                                 // "whsec_<base64>" or a raw string
    header: name => headers.TryGetValue(name, out var v) ? v : null, // header lookup function
    payload: rawBodyBytes,                                            // byte[] (a string overload also exists)
    tolerance: TimeSpan.FromMinutes(5),                               // default 5 minutes; TimeSpan.Zero disables
    now: null);                                                       // optional, for tests
```

| SDK | Returns | Default tolerance | Failure |
| --- | --- | --- | --- |
| TypeScript | `Promise<string>` (the `webhook-id`) | 300 s | rejects with `WebhookVerificationError` |
| Python | `str` (the `webhook-id`) | 300 s | raises `WebhookVerificationError` |
| Go | `(string, error)` | none, you pass it | error wrapping `pushq.ErrVerification` |
| Java | `void` (read the id from the header) | none, you pass it | throws unchecked `WebhookVerificationException` |
| .NET | `string` (the `webhook-id`) | 5 minutes (`Webhooks.DefaultTolerance`) | throws `WebhookVerificationException` |

In every SDK:

- A secret that starts with `whsec_` is base64-decoded after the prefix. Any other string is used as raw UTF-8 key bytes.
- The tolerance applies in both directions, to timestamps in the past and in the future.
- The signature header may contain several space-separated `v1,<signature>` entries. Verification passes if any of them matches, and the comparison is constant-time.

Every SDK also exports a `sign` function (`sign`, `pushq.Sign`, `Webhooks.sign`, `Webhooks.Sign`). It produces a `v1,<base64>` signature so you can test your endpoint without a pushq server.

## Runtime and version support

| SDK | Package | Requires | Notes |
| --- | --- | --- | --- |
| TypeScript | npm `pushq` | Node.js 18.17+, Bun, Deno, Cloudflare Workers and other runtimes with `fetch` | ESM and CommonJS builds with type declarations; no runtime dependencies. Server-side only: it would expose your API key in a browser, and the API sends no CORS headers. |
| Python | PyPI `pushq` | Python 3.9+ | Depends only on `httpx>=0.25`. Ships type hints (`py.typed`). Sync `Pushq` and async `AsyncPushq`. |
| Go | `github.com/blissfulrays/pushq/sdks/go` | Go 1.22+ | Every method takes a `context.Context`. |
| Java | `io.github.blissfulrays:pushq` (build from source for now) | Java 11+ | Synchronous and thread-safe. Depends on `jackson-databind` and `jackson-datatype-jsr310`. JPMS module name `io.pushq`. |
| .NET | NuGet `Pushq` | `netstandard2.0` (.NET Framework 4.6.2+, .NET Core, .NET 5+) and `net10.0` | No dependencies on `net10.0`. On `netstandard2.0` it pulls in `System.Text.Json`. |

:::caution
- **TypeScript:** `verifySignature` uses the global Web Crypto API (`crypto.subtle`). On Node.js 18 that global is not enabled by default, so use Node.js 20 or later for receivers. On Node 18 you can set `globalThis.crypto = require("node:crypto").webcrypto` at startup.
- **Python:** `AsyncPushq` does not have `create_queue`, `patch_queue` or `list_queues`. Use the sync client for those.
:::

## What the SDKs don't cover

The SDKs wrap queue and task operations only. To create, list or revoke API keys, manage team members, or read the server version (`GET /v1/version`), use the [console](https://console.pushqueue.dev/) or call the [REST API](https://pushqueue.dev/docs/reference/api/) directly. See [API keys](https://pushqueue.dev/docs/guides/api-keys/) and [Team members](https://pushqueue.dev/docs/guides/team-members/).
