# Create a Synced Database Table

Launch stage: Public Preview

`POST /api/2.0/database/synced_tables`

Create a Synced Database Table.

API scopes: postgres

## Request body

- `name` (string, required)
  Full three-part (catalog, schema, table) name of the table.
- `database_instance_name` (string, optional, Input only)
  Name of the target database instance. This is required when creating synced database tables in standard catalogs.
   This is optional when creating synced database tables in registered catalogs. If this field is specified
   when creating synced database tables in registered catalogs, the database instance name MUST
   match that of the registered catalog (or the request will be rejected).
- `logical_database_name` (string, optional, Input only)
  Target Postgres database object (logical database) name for this table.
  
   When creating a synced table in a registered Postgres catalog, the
   target Postgres database name is inferred to be that of the registered catalog.
   If this field is specified in this scenario, the Postgres database name MUST
   match that of the registered catalog (or the request will be rejected).
  
   When creating a synced table in a standard catalog, this field is required.
   In this scenario, specifying this field will allow targeting an arbitrary postgres database.
   Note that this has implications for the `create_database_objects_is_missing` field in `spec`.
- `spec` (object, optional)
  - `scheduling_policy` (string, optional)
    Scheduling policy of the underlying pipeline.
    Possible values:
    - `SYNCED_TABLE_SCHEDULING_POLICY_UNSPECIFIED`
    - `CONTINUOUS`
    - `TRIGGERED`
    - `SNAPSHOT`
  - `source_table_full_name` (string, optional)
    Three-part (catalog, schema, table) name of the source Delta table.
  - `primary_key_columns` (array of string, optional)
    Primary Key columns to be used for data insert/update in the destination.
  - `timeseries_key` (string, optional)
    Time series key to deduplicate (tie-break) rows with the same primary key.
  - `existing_pipeline_id` (string, optional, Input only)
    At most one of existing_pipeline_id and new_pipeline_spec should be defined.
    
     If existing_pipeline_id is defined, the synced table will be bin packed into the existing pipeline
     referenced. This avoids creating a new pipeline and allows sharing existing compute.
     In this case, the scheduling_policy of this synced table must match the scheduling policy of the existing pipeline.
  - `create_database_objects_if_missing` (boolean, optional, Input only)
    If true, the synced table's logical database and schema resources in PG
     will be created if they do not already exist.
    Default: `true`
  - `new_pipeline_spec` (object, optional, Input only)
    At most one of existing_pipeline_id and new_pipeline_spec should be defined.
    
     If new_pipeline_spec is defined, a new pipeline is created for this synced table. The location pointed to is used
     to store intermediate files (checkpoints, event logs etc). The caller must have write permissions to create Delta
     tables in the specified catalog and schema. Again, note this requires write permissions, whereas the source table
     only requires read permissions.
    - `storage_catalog` (string, optional)
      This field needs to be specified if the destination catalog is a managed postgres catalog.
      
       UC catalog for the pipeline to store intermediate files (checkpoints, event logs etc).
       This needs to be a standard catalog where the user has permissions to create Delta tables.
    - `storage_schema` (string, optional)
      This field needs to be specified if the destination catalog is a managed postgres catalog.
      
       UC schema for the pipeline to store intermediate files (checkpoints, event logs etc).
       This needs to be in the standard catalog where the user has permissions to create Delta tables.
    - `budget_policy_id` (string, optional, Beta)
      Budget policy to set on the newly created pipeline.

## Returns

Returns the SyncedDatabaseTable object.

## Response

```json
{
  "name": "string",
  "effective_database_instance_name": "string",
  "effective_logical_database_name": "string",
  "spec": {
    "scheduling_policy": "CONTINUOUS",
    "source_table_full_name": "string",
    "primary_key_columns": [
      "string"
    ],
    "timeseries_key": "string"
  },
  "unity_catalog_provisioning_state": "PROVISIONING",
  "data_synchronization_status": {
    "detailed_state": "SYNCED_TABLE_PROVISIONING",
    "message": "string",
    "provisioning_status": {},
    "continuous_update_status": {},
    "triggered_update_status": {},
    "failed_status": {},
    "pipeline_id": "string",
    "last_sync": {}
  }
}
```

