/projects/{project_id}/branches/{branch_id}/schemaRetrieve database schemaRetrieves the database schema. Specify lsn or timestamp (not both) to read at a point in time; omit both to read from the database's head.
Parameters
project_idstringpathrequiredThe Neon project ID
branch_idstringpathrequiredThe branch ID
db_namestringqueryrequiredName of the database for which the schema is retrieved
lsnstringqueryThe Log Sequence Number (LSN) for which the schema is retrieved
timestampstring · date-timequeryThe point in time for which the schema is retrieved
formatstringqueryThe format of the schema to retrieve. Possible values: - `sql` (default) - `json`
Responses
jsonobjectShow child attributes
tablesarray of objectrequiredTables present in the branch schema.
Show child attributes
Show array items
columnsarray of objectrequiredColumns belonging to this table, each describing a column's name and attributes.
Show child attributes
Show array items
generatedbooleanWhether the column is a generated (computed) column
namestringrequiredName of the column.
typestringrequiredPostgres data type of the column, for example "integer" or "text".
constraintsarray of objectTable constraints defined in the branch schema, such as primary key, foreign key, unique, and check constraints.
Show child attributes
Show array items
columnsarray of stringrequiredColumn names participating in this constraint
Show child attributes
namestringOptional name of the constraint
referenced_tableobjectFor foreign keys - the referenced table information
Show child attributes
columnsarray of stringrequiredNames of the referenced columns
Show child attributes
schemastringrequiredSchema of the referenced table
tablestringrequiredName of the referenced table
typestringrequiredType of constraint. Possible values: `primary_key`, `unique`, `foreign_key`
namestringrequiredName of the table within the schema.
schemastringrequiredPostgres schema (namespace) that contains the table, for example `public`.
sqlstringBranch schema expressed as SQL DDL statements.
{
"json": {
"tables": [
{
"columns": [
{
"generated": true,
"name": "string",
"type": "string"
}
],
"constraints": [
{
"columns": [
"string"
],
"name": "string",
"referenced_table": {
"columns": [
"string"
],
"schema": "string",
"table": "string"
},
"type": "string"
}
],
"name": "string",
"schema": "string"
}
]
},
"sql": "string"
}codestringrequiredmessagestringrequiredError message
request_idstringUnique identifier for the request, useful for debugging. You can set this value manually by including an `X-Request-ID` header in the request. If not provided, the value will be generated automatically.
{
"code": "",
"message": "string",
"request_id": "string"
}