---
updatedAt: 2026-04-22T14:30:04.000Z
agentTools:
  projectIndex: https://developers.sqldbm.com/llms.txt
---

# Get alterscript for the latest branch revisions

Returns the SQL that updates a database from the branch's previous revision to its latest one. Only
what differs is included.

# OpenAPI definition

```json
{
  "openapi": "3.0.4",
  "info": {
    "title": "SqlDBM.OpenAPI",
    "description": "Requests are authorised with a bearer token. Endpoints that create something return 202 and finish the work\nafter responding.\n\nRequest bodies may be compressed with gzip, deflate, br (Brotli) or zstd using the Content-Encoding header.\nThe limit is 15 MB on the wire and 100 MB once decompressed. File uploads state their own limit.",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.sqldbm.com"
    }
  ],
  "paths": {
    "/projects/{projectId}/branches/{branchId}/alter": {
      "get": {
        "tags": [
          "Get project metadata and DDL (branch-scoped)"
        ],
        "summary": "Get alterscript for the latest branch revisions",
        "description": "Returns the SQL that updates a database from the branch's previous revision to its latest one. Only\nwhat differs is included.",
        "parameters": [
          {
            "name": "projectId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          },
          {
            "name": "branchId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Alterscript retrieved successfully",
            "content": {
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/StringResponseData"
                },
                "example": "<ResponseData xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">\n  <Data>ALTER TABLE [dbo].[Users] ADD [Email] NVARCHAR(255) NOT NULL;\nALTER TABLE [dbo].[Orders] DROP COLUMN [LegacyCode];</Data>\n  <Message i:nil=\"true\" />\n</ResponseData>"
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StringResponseData"
                },
                "example": {
                  "data": "ALTER TABLE [dbo].[Users] ADD [Email] NVARCHAR(255) NOT NULL;\nALTER TABLE [dbo].[Orders] DROP COLUMN [LegacyCode];"
                }
              }
            }
          },
          "400": {
            "description": "The API call was not formed correctly",
            "content": {
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "status": 400,
                  "type": "Invalid_Syntax",
                  "message": "The API call was not formed correctly"
                }
              }
            }
          },
          "401": {
            "description": "The API call was not made by an authorized agent",
            "content": {
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "status": 401,
                  "type": "Unauthorized",
                  "message": "The API call was not made by an authorized agent"
                }
              }
            }
          },
          "403": {
            "description": "The requested resource or operation is forbidden to the calling user",
            "content": {
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "status": 403,
                  "type": "Forbidden",
                  "message": "The requested resource or operation is forbidden to the calling user"
                }
              }
            }
          },
          "404": {
            "description": "Project, revision, or object not found",
            "content": {
              "application/json": {
                "example": {
                  "status": 404,
                  "type": "Not_Found",
                  "message": "Project, revision, or object not found"
                }
              }
            }
          },
          "429": {
            "description": "The request was rejected due to high inbound volume",
            "content": {
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "status": 429,
                  "type": "Too_Many_Requests",
                  "message": "The request was rejected due to high inbound volume"
                }
              }
            }
          },
          "500": {
            "description": "An unexpected error has occurred and will require support",
            "content": {
              "application/xml": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "status": 500,
                  "type": "Server_Error",
                  "message": "An unexpected error has occurred and will require support"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "status": {
            "type": "integer",
            "format": "int32"
          },
          "type": {
            "type": "string",
            "nullable": true
          },
          "message": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false,
        "description": "Standard error response returned by the API for non-2xx status codes."
      },
      "StringResponseData": {
        "type": "object",
        "properties": {
          "data": {
            "type": "string",
            "nullable": true
          },
          "message": {
            "type": "string",
            "nullable": true
          }
        },
        "additionalProperties": false
      }
    },
    "securitySchemes": {
      "OpenApiBearerAuthentication": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    }
  },
  "security": [
    {
      "OpenApiBearerAuthentication": []
    }
  ],
  "tags": [
    {
      "name": "Get project metadata and DDL (branch-scoped)"
    }
  ]
}
```