Create a PostgreSQL user

Create a user with a strong generated password. The user is added to PostgreSQL shortly after the response. Get the password with betterstack postgres-user credentials. An instance can have up to 25 users.

POST https://{availability_zone}.betterstackcloud.com/v1/postgres/{postgres_id}/users
postgres_id string required

The ID of the PostgreSQL instance.

Authorization string required

Bearer $TOKEN

Content-Type string

application/json

username string required

The user name in PostgreSQL. Accepts up to 63 lowercase letters, digits and underscores, starting with a letter or an underscore. Can't be changed after the user is created. Can't be postgres or pgbouncer or start with pg_.

privileges object

The user's access to each database, as an object that maps a database name to an access level, such as {"appdb": "read_write"}. A database that isn't in the object gets no access. read can read the tables in the public schema. read_write can also add, change and delete rows and run functions, but can't create tables. all can also create tables and schemas and maintain them, such as with VACUUM. none gives no access. Each key must be a database of this instance. Leave it out on create for no access to any database. An update replaces the whole object, and leaving it out removes all access. Accepts any keys.

202 Accepted
{
  "id": "example",
  "username": "example",
  "default_user": false,
  "privileges": {
    "appdb": "read_write"
  },
  "created_at": "2026-07-01T12:00:00.000Z"
}

Returns the newly created PostgreSQL user.

id string

The user's ID, a UUID.

username string

The user name in PostgreSQL. Accepts up to 63 lowercase letters, digits and underscores, starting with a letter or an underscore. Can't be changed after the user is created.

default_user boolean

Whether this is the instance's default admin user. We manage the default user's access, and the default user can't be deleted.

privileges object

The user's access to each database, as an object that maps a database name to an access level, such as {"appdb": "read_write"}. A database that isn't in the object gets no access. read can read the tables in the public schema. read_write can also add, change and delete rows and run functions, but can't create tables. all can also create tables and schemas and maintain them, such as with VACUUM. none gives no access.

created_at datetime

When the user was created. In ISO 8601 format, such as 2026-07-01T12:00:00Z.