---
title: "Get AST for source code"
method: POST
path: "/api/v2/static-analysis/static-analysis-server/get-ast"
tags: ["Security Monitoring"]
---

# Get AST for source code

`POST /api/v2/static-analysis/static-analysis-server/get-ast`

Parse source code into an abstract syntax tree (AST) for the specified language.

## Request body

- GetAstRequest — The request payload for parsing source code into an abstract syntax tree.
  - `data` GetAstRequestData, required — The primary data object in the get-AST request.
    - `attributes` GetAstRequestDataAttributes, required — The attributes of the get-AST request, containing the source code to parse.
      - `code` string, required — The base64-encoded source code to parse into an abstract syntax tree.
      - `file_encoding` string, required — The encoding of the source code file (must be utf-8).
      - `language` string, required — The programming language of the source code to parse.
    - `id` string — An optional identifier for the get-AST request resource.
    - `type` 'get_ast_request', required — Get AST request resource type.

## Response `200`

OK

- GetAstResponse — The response payload containing the parsed abstract syntax tree.
  - `data` GetAstResponseData, required — The primary data object in the get-AST response.
    - `attributes` GetAstResponseDataAttributes, required — The attributes of the get-AST response, containing the parsed abstract syntax tree.
      - `ast` object, required — The parsed abstract syntax tree as a JSON object.
    - `id` string — The identifier of the get-AST response resource.
    - `type` 'get_ast_response', required — Get AST response resource type.

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `429` — Too many requests

---

[API](https://skmtc.net/datadog/apis/api-v2.md) · [All operations](https://skmtc.net/datadog/apis/api-v2/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/datadog/api-v2/versions/da68bf029e4c/schema)
