Copy a table’s structure with the Inbound API

Create an empty personal test table from an existing table’s fields and verify that the copy has no records.

Use a simple test table with standalone fields. The API key’s acting user needs access to the source table, permission to export from it, and permission to create the destination table. The copy is a personal table in the same workspace.

Prepare the copy

  1. Read the source with GET /entities/{entityId}. Save data.updatedAt as NIXA_SOURCE_UPDATED_AT. Use the base URL from API Access and load the key from your secret manager.
  2. Replace 123 with the source table’s ID. Set copyRecords explicitly to false to create an empty copy. Leaving it out requests a record copy.
curl --silent --show-error --fail-with-body \
  --request POST "${NIXA_API_BASE_URL}/schema-changes/proposals" \
  -H "X-API-Key: ${NIXA_API_KEY}" \
  -H 'Content-Type: application/json' \
  --data "{\"operation\":{\"kind\":\"duplicate_table\",\"entityId\":123,\"name\":\"api_structure_copy\",\"displayName\":\"API structure copy\",\"copyRecords\":false,\"sourceSchemaVersion\":\"${NIXA_SOURCE_UPDATED_AT}\"}}"

HTTP 201 returns the proposal in data. Proceed when data.status is ready and data.operations shows the expected new table and fields. Mainbase can adjust the proposed name to make it unique, so keep the name shown in the reviewed proposal. Review data.issues and data.impact before applying. Saved views and table relationships need to be configured on the copy. Formulas that depend on related records can prevent preparation.

Apply and verify the empty table

Set NIXA_PROPOSAL_ID and NIXA_PROPOSAL_HASH from the reviewed proposal. Use a unique NIXA_APPLICATION_KEY for this application.

curl --silent --show-error --fail-with-body \
  --request POST "${NIXA_API_BASE_URL}/schema-changes/proposals/${NIXA_PROPOSAL_ID}/apply" \
  -H "X-API-Key: ${NIXA_API_KEY}" \
  -H 'Content-Type: application/json' \
  --data "{\"proposalHash\":\"${NIXA_PROPOSAL_HASH}\",\"idempotencyKey\":\"${NIXA_APPLICATION_KEY}\",\"confirmDestructive\":false}"
  1. Save data.application.applicationId from the response and check GET /schema-changes/applications/{applicationId} until data.status is verified. If it is failed or recovery_required, check that application before preparing another copy.
  2. Find the reviewed destination name in GET /entities and use its ID to read the new table’s schema. Check data.ownershipType is PERSONAL and verify its fields. Call GET /entities/{entityId}/records with the new table’s ID and confirm that data is empty.

If the apply response is interrupted, resend the same proposal ID, hash, application key, and confirmation value. After a conflict, check the application and the destination table before making a new proposal.

Ask Mainbase AI

Ask about any feature in Mainbase. Find a setting, get step-by-step guidance, or troubleshoot a problem.

Open the AI assistant

Copy a question to get started

  • How do I create a Kanban view?
  • How do I invite a teammate?
  • Why is a record missing from this view?