> For the complete documentation index, see [llms.txt](https://developer.abacum.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.abacum.ai/api-reference/models/get-model-logic.md).

# Get model logic

Retrieve the calculation logic for every variable in the requested model: actuals formulas, dimension aggregation types, formatting metadata, and (when `scenario_id` is provided) the version-specific formulas for that scenario.

When `scenario_id` is omitted, only actuals information is returned.

```json
{"openapi":"3.0.0","info":{"title":"Abacum public API","version":"1.0.0"},"tags":[{"name":"Models","description":"List, create, rename and move models, and read their actuals, scenario and rolling data and their logic."}],"servers":[{"url":"https://api.abacum.io","description":"Prod environment"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"An access token from the token endpoint, sent as `Authorization: Bearer <access_token>`. Use it to try an endpoint from this page. The token carries the permissions of its user, so use a user with the lowest role that fits the call."}},"parameters":{"ModelId":{"name":"model_id","in":"path","required":true,"schema":{"type":"string","format":"uuid"},"description":"The ID of the model. It must be a UUID. Any other value returns a `404` with an HTML page."}},"schemas":{"ErrorMessage":{"type":"object","required":["error"],"properties":{"error":{"type":"string"}}},"DetailMessage":{"type":"object","required":["detail"],"properties":{"detail":{"type":"string"}}}},"responses":{"TooManyRequests20PerMinute":{"description":"Rate limit exceeded: 20 requests per minute for the same user and URL. Wait the number of seconds in the `Retry-After` header, then retry.","headers":{"Retry-After":{"description":"Seconds to wait before the next request.","schema":{"type":"integer"}},"X-Request-ID":{"$ref":"#/components/headers/XRequestID"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DetailMessage"}}}},"InternalServerError":{"description":"An unexpected error on our side. The response has an empty body. Repeat the request, and contact support if it keeps failing.","headers":{"X-Request-ID":{"$ref":"#/components/headers/XRequestID"}}}},"headers":{"XRequestID":{"description":"Identifier of this request. Quote it when you contact support so they can find the exact request. A server-side client can set it by sending an `X-Request-ID` request header of 1 to 64 characters from `A-Za-z0-9_-`; any other value is replaced by a generated one. Browsers can read this header but cannot send their own. The value identifies a request for support, but it is not proof that only one request used it.","schema":{"type":"string"}}}},"paths":{"/public-api/models/{model_id}/logic":{"get":{"summary":"Get model logic","description":"Retrieve the calculation logic for every variable in the requested model: actuals formulas,\ndimension aggregation types, formatting metadata, and (when `scenario_id` is provided)\nthe version-specific formulas for that scenario.\n\nWhen `scenario_id` is omitted, only actuals information is returned.\n","operationId":"getModelLogic","tags":["Models"],"parameters":[{"$ref":"#/components/parameters/ModelId"},{"name":"scenario_id","in":"query","required":false,"schema":{"type":"string","format":"uuid"},"description":"When provided, each variable includes the version's formulas and aggregation type for that scenario."}],"responses":{"200":{"description":"Per-variable calculation logic for the model.","content":{"application/json":{"schema":{"type":"object","required":["data"],"properties":{"data":{"type":"array","items":{"type":"object","required":["id","code","name","description","section","group","dimensions","dimensions_display","actuals","version","time_aggregation_type","favorable","format","currency_symbol","decimals","proportion_of","proportion_of_type"],"properties":{"id":{"type":"string","format":"uuid"},"code":{"type":"string"},"name":{"type":"string"},"description":{"type":"string","nullable":true,"description":"Free-text description of the variable. `null` when the variable has no description."},"section":{"type":"string","nullable":true,"description":"Name of the section the variable belongs to. `null` when the variable has no section."},"section_id":{"type":"string","format":"uuid","nullable":true,"description":"ID of the section the variable belongs to. `null` when the variable has no section."},"group":{"type":"string","nullable":true,"description":"Name of the summary group the variable belongs to. `null` when the variable is not part of a group."},"dimensions":{"type":"array","items":{"type":"string"},"description":"Dimension codes attached to the variable for the requested version. When `scenario_id` is omitted, this is the actuals dimensions."},"dimensions_display":{"type":"array","items":{"type":"string"},"description":"Human-readable labels for `dimensions`, in the same order."},"actuals":{"type":"object","required":["formula","formula_display","dimensions_aggregation_type"],"properties":{"formula":{"type":"string","description":"Actuals formula as authored, using variable codes."},"formula_display":{"type":"string","description":"Same formula with variable codes replaced by variable names."},"dimensions_aggregation_type":{"type":"string","enum":["SUM","AVERAGE","FUNCTION",null],"nullable":true}}},"version":{"type":"object","nullable":true,"description":"Version-specific logic for the requested scenario. `null` when `scenario_id` is omitted.","required":["dimensions_aggregation_type","formulas"],"properties":{"dimensions_aggregation_type":{"type":"string","enum":["SUM","AVERAGE","FUNCTION",null],"nullable":true},"formulas":{"type":"array","items":{"type":"object","required":["formula","formula_display"],"properties":{"formula":{"type":"string"},"formula_display":{"type":"string"},"id":{"type":"string","format":"uuid","nullable":true,"description":"ID of the version formula. `null` when the version runs the actuals formula (\"same as actuals\")."},"dimension_items":{"type":"array","items":{"type":"string"},"description":"Dimension items the formula applies to, in the order of `dimensions`. Empty when it applies to the whole variable."}}}}}},"time_aggregation_type":{"type":"string","enum":["SUM","AVERAGE","FUNCTION","FIRST","LAST",null],"nullable":true},"favorable":{"type":"boolean"},"format":{"type":"string","enum":["number","percentage","currency",""],"description":"Display format. Empty when the variable has none."},"currency_symbol":{"type":"string","nullable":true},"decimals":{"type":"integer"},"proportion_of":{"type":"string","nullable":true},"proportion_of_type":{"type":"string","enum":["SUMMARY_GROUP","VARIABLE","",null],"nullable":true},"updated_at":{"type":"string","format":"date-time","description":"When the variable was last saved."}}}}}}}}},"400":{"description":"Invalid request - `scenario_id` is not a valid UUID.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"403":{"description":"One of three causes:\n\n- The bearer token is missing, invalid or expired. The response has an empty body.\n- The token's user is not an Admin or Super Admin. The body is `{\"detail\": \"You do not have permission to perform this action.\"}`.\n- The model is restricted and the user cannot access it. The response has an empty body.\n\nThe API answers `403` for a bad token, not `401`.\n","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DetailMessage"}}}},"404":{"description":"Not found - the model or scenario does not exist in the user's organization. The body is `{\"error\": \"<message>\"}`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorMessage"}}}},"429":{"$ref":"#/components/responses/TooManyRequests20PerMinute"},"500":{"$ref":"#/components/responses/InternalServerError"}}}}}}
```
