Diagrams

Create a diagram

Create a diagram in the token's team from SQL DDL or a schema patch. Requires a token with the write ability.

Send exactly one of ddl or schema. A schema patch is applied inline, so the response is 201 with the finished diagram. SQL DDL is parsed by a background import: the response is 201 when that import finishes within the request (status is ready, or failed if the SQL could not be used), and 202 with status: importing when it does not. In the 202 case, poll GET /diagrams/{uuid} every poll_after_seconds until status is ready or failed; the schema endpoints return 409 until then.

Retrying the same request (same token, name, driver, and payload) returns the diagram the first attempt made, with replayed: true, rather than creating a second one: 200 once it is ready, 202 while its import is still running. The window is the running import, plus two minutes after it finishes. A failed create is never returned, so a retry makes a fresh attempt.

Canvas positions and sizes (left, top, width, height) are not accepted here — the layout is computed. Rate limit: 10 requests/minute per token.

post/diagrams

Request

  • Base URL
    https://api.drawsql.app/v1
  • Auth
    HTTP bearer

Request body

ddlstring

SQL DDL (CREATE TABLE / ALTER TABLE statements). Max 200KB.

namestring

The diagram's name. Defaults to "Untitled".

driver'mysql' | 'pgsql' | 'sqlsrv'

The database dialect the schema is written in.

Response

A retry of a request that already created a diagram, which is now ready. The body is the existing diagram, with replayed: true.

warningsstring[] required

Non-fatal notes about the submitted patch, such as fields that were dropped because they are not part of the documented format.

replayedboolean required

Whether this response returns a diagram an earlier identical request created.

poll_after_secondsinteger required

How long to wait between polls of GET /diagrams/{uuid} while importing.

Example response

{
  "data": {
    "error": {
      "code": "parse_failed"
    }
  }
}

Changes

No recorded changes to this operation across all 1 revision of this API.