---
title: "Grant Script Endpoint"
method: POST
path: "/v1/connectors/{connector_id}/grant-script"
tags: ["v1-connectors"]
---

# Grant Script Endpoint

`POST /v1/connectors/{connector_id}/grant-script`

Return the minimal-privilege psql script the customer should run on their source
PostgreSQL to grant the replication user the access pgstream needs.

Output shape (idempotent — same connector + same selection => same script):
    {
      "sql": "...complete psql artifact...",
      "source_provider": "rds" | "supabase" | "cloudsql" | "vanilla" | ...,
      "replication_username": "<the username on the connector>",
      "schemas_per_database": {"<db>": ["<schema>", ...], ...}
    }

The SQL covers (per ARD-1051):
  - the replication role attribute (provider-specific line),
  - GRANT CONNECT + GRANT CREATE per database (so pgstream can
    CREATE PUBLICATION and its bookkeeping schema),
  - GRANT USAGE + SELECT on tables and sequences per schema,
  - ALTER DEFAULT PRIVILEGES for both TABLES and SEQUENCES so
    objects added to source AFTER the grants run also replicate.

Errors:
  - 404 — connector not found / no RLS access.
  - 422 — connector is not a PostgreSQL service, discovery has not
    run, no schemas selected, or connection_details is missing the
    username field. The detail string names the exact next step.
  - 500 — Key Vault decryption failed.

Note for RDS sources: this endpoint emits the GRANT line; the
rds.logical_replication parameter still has to be set to 1 in the
cluster's parameter group and the instance restarted before logical
replication will work. The grant-script comment header reminds the
customer.

## Path parameters

- `connector_id` string, required

## Response `200`

Successful Response

- unknown

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/tryardent/apis/fastapi.md) · [All operations](https://skmtc.net/tryardent/apis/fastapi/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/tryardent/fastapi/versions/f92d8d54bae2/schema)
