API Guidance

Language-neutral request snippets and guidance for various endpoints in ATLAS

Conventions

  • {BASE} = https://<host>/atlas/api/v2. Authenticated calls send Authorization: Bearer <access_token> (from POST /authentication/login/). The two AIMS calls (CDE-CALL-11, 12) use {HOST}/aimsapi and Authorization: Token <access_token>.
  • tenant_id is a query parameter, used for the role check. This version assumes the tenant does not require Option / OptionVersion on its calls.
  • Request bodies are JSON (Content-Type: application/json).

Confidence: the calls marked (confirmed) are taken from working samples in this repo. Those marked (to confirm) are best estimates; check the endpoint or payload before publishing.

Fetching Metadata

Endpoints and parameters are from the ATLAS API v2 OpenAPI spec; the example values and responses are illustrative and the calls have not been run.

Asset class metadata (including attributes)

One class, by class code. Each result includes the class's display_name, meta_type, the system / sub_system / function / sub_function classification, and its attributes (code, name, type, unit, mandatory flag, predetermined list):

GET {BASE}/asset_type/?tenant_id=447&class_code=TrackSection

All classes, paged (repeat with page=2, 3, ... while next is not null). Optional filters: display_name, system_name, sub_system_name, function_name, sub_function_name:

GET {BASE}/asset_type/?tenant_id=447&page=1&page_size=100

Attributes of one class on their own:

GET {BASE}/asset_type/attribute/?asset_type_class_code=TrackSection&page_size=100

Location hierarchy

Locations are a flat paged list; the tree is built from each location's level and parent:

GET {BASE}/location/?page=1&page_size=100
{
  "count": 3,
  "next": null,
  "results": [
    {"id": 1, "level": 1, "code": "MRS",         "name": "MRS", "parent": null},
    {"id": 2, "level": 2, "code": "MRS-M12",     "name": "M12", "parent": "MRS"},
    {"id": 3, "level": 3, "code": "MRS-M12-ATL", "name": "ATL", "parent": "MRS-M12"}
  ]
}

(Abbreviated: each location also has location_id, change_flag, changeset, tenant, modified_at and attributes.) A location with parent: null is a root. The sample location data in this workspace uses the same pattern (parent is the parent's code). One location by id:

GET {BASE}/location/2/

Attributes defined for locations:

GET {BASE}/location/attribute/

Asset search

POST {BASE}/asset/search/ is the general search used by CDE-CALL-3 and the samples in this repo. The parameters and filter fields below come from the ATLAS API v2 OpenAPI spec and the search samples; the example values and response are illustrative and the calls have not been run.

Query parameters: tenant_id (role check), page, page_size, ordering (field to sort by), return_geometry=1 (include GeoJSON geometry / centroid).

Body: tenant (or contract_id) is required. filters is a list of groups; each group has an operator (AND / OR) and a list of lookups, and groups can be nested through their own filters. search is an optional free-text term. Each lookup is {"name": <field>, "lookup": <operator>, "value": <value>}.

Filterable names: class_code, tag_code, asset_id, asset_revision_id, change_flag, changeset, discipline, sub_discipline, function, sub_functional_unit, location, modified_at, import_source, imported_at, geometry and attributes.<AttributeName>. Lookups include exact, iexact, contains, icontains, startswith, in, gt, gte, lt, lte and isnull.

Assets of one class, latest revision

POST {BASE}/asset/search/?tenant_id=447&page=1&page_size=100&ordering=modified_at
{
  "tenant": 447,
  "filters": [
    {
      "operator": "AND",
      "lookups": [
        {"name": "class_code",  "lookup": "exact", "value": "TrackSection"},
        {"name": "change_flag", "lookup": "exact", "value": "latest"}
      ]
    }
  ]
}

Without the change_flag lookup the search returns every revision of each asset (latest, revised, rolled_back and pending). Repeat with page=2, 3, ... while next is not null.

Filter on an attribute and a list of ids

POST {BASE}/asset/search/?tenant_id=447
{
  "tenant": 447,
  "filters": [
    {
      "operator": "AND",
      "lookups": [
        {"name": "change_flag", "lookup": "exact", "value": "latest"},
        {"name": "asset_id", "lookup": "in", "value": [202, 203, 204]},
        {"name": "attributes.Description", "lookup": "icontains", "value": "realigned"}
      ]
    }
  ]
}

One asset by tag code

POST {BASE}/asset/search/?tenant_id=447
{
  "tenant": 447,
  "filters": [
    {
      "operator": "AND",
      "lookups": [
        {"name": "tag_code", "lookup": "exact", "value": "1052a7f6-d2f7-46da-b501-d97b214d750f"}
      ]
    }
  ]
}

Revisions in a changeset

POST {BASE}/asset/search/?tenant_id=447&page=1&page_size=100
{
  "tenant": 447,
  "filters": [
    {
      "operator": "AND",
      "lookups": [
        {"name": "changeset", "lookup": "exact", "value": 1241}
      ]
    }
  ]
}

Combine groups with OR

Latest revisions of class TrackSection or TrackNode:

POST {BASE}/asset/search/?tenant_id=447
{
  "tenant": 447,
  "filters": [
    {
      "operator": "AND",
      "lookups": [
        {"name": "change_flag", "lookup": "exact", "value": "latest"}
      ]
    },
    {
      "operator": "OR",
      "lookups": [
        {"name": "class_code", "lookup": "exact", "value": "TrackSection"},
        {"name": "class_code", "lookup": "exact", "value": "TrackNode"}
      ]
    }
  ]
}

Free-text search

POST {BASE}/asset/search/?tenant_id=447
{
  "tenant": 447,
  "search": "Switch 12",
  "filters": [
    {
      "operator": "AND",
      "lookups": [
        {"name": "change_flag", "lookup": "exact", "value": "latest"}
      ]
    }
  ]
}

Response

A paged list of asset revisions (abbreviated; each result has more fields):

{
  "count": 2,
  "next": null,
  "previous": null,
  "results": [
    {
      "id": 98765,
      "change_flag": "latest",
      "changeset": 1198,
      "attributes": {"Description": "Track section realigned"},
      "asset": {
        "id": 202,
        "tag_code": "e5f6g7h8-0000-0000-0000-000000000000",
        "asset_type": {"class_code": "TrackSection", "display_name": "Track Section"},
        "related_assets_as_source": [{"target_asset": 203}],
        "related_assets_as_target": [{"source_asset": 101}]
      }
    }
  ]
}

related_assets_as_source[].target_asset are the child asset ids and related_assets_as_target[].source_asset the parent ids.

Filtering on Json attributes (nested keys, arrays of objects) is covered in search_assets_by_json_attribute.md.

Editing of Assets

Get changesets created by you

GET {BASE}/asset/changeset/?tenant_id=447&available_active_changesets=1

Returns the current user's changesets still work in progress. An empty results list means none are open.

Get assets with published + your WIP data

Taken from the track hierarchy sample (fetch_trk_model_assets). The design is read as a hierarchy: top-level track assets first, then each level of children, with return_geometry=1 on every call so each result carries its GeoJSON geometry (WGS84, [lon, lat, height]). Every call is paged (page, page_size=100): repeat with page=2, 3, ... while next is not null.

Step 1, the published root assets: latest revision of every top-level TrackSection (an asset with relations and no parent):

POST {BASE}/asset/search/relation/related/?tenant_id=447&return_geometry=1&page=1&page_size=100
{
  "tenant": 447,
  "filters": [
    {
      "operator": "AND",
      "lookups": [
        {"name": "class_code",  "lookup": "exact", "value": "TrackSection"},
        {"name": "change_flag", "lookup": "exact", "value": "latest"}
      ]
    }
  ]
}

Step 2, the children, one call per level: collect the child ids from the previous results, then fetch them in batches (the sample uses 30 ids per call):

POST {BASE}/asset/search/?tenant_id=447&return_geometry=1&page=1&page_size=100
{
  "tenant": 447,
  "filters": [
    {
      "operator": "AND",
      "lookups": [
        {"name": "asset_id", "lookup": "in", "value": [202, 203, 204]}
      ]
    }
  ]
}

Each result embeds its relations: asset.related_assets_as_source[].target_asset are the child ids (use these for the next level) and asset.related_assets_as_target[].source_asset are the parent ids. Repeat step 2 until a level returns no new ids. Assets reached from more than one parent are fetched once.

Step 3, your WIP data: every revision held in your open changeset (the id comes from CDE-CALL-2):

POST {BASE}/asset/search/?tenant_id=447&return_geometry=1&page=1&page_size=100
{
  "tenant": 447,
  "filters": [
    {
      "operator": "AND",
      "lookups": [
        {"name": "changeset", "lookup": "exact", "value": 1241}
      ]
    }
  ]
}

Merge: for each asset id (asset.id), use the revision from step 3 if there is one, otherwise the published one from steps 1 and 2. New assets created in the changeset appear only in step 3. Skip step 3 when there is no open changeset. A viewer-only user gets steps 1 and 2 only (read-only design).

The asset_id search in step 2 has no change_flag filter, so it returns every revision of each asset (latest, revised, rolled_back and pending). Keep the one with change_flag = latest per asset, as the schematic sample does, or add {"name": "change_flag", "lookup": "exact", "value": "latest"} to the step 2 filter (the hierarchy sample sends only the asset_id lookup).

Publish or roll back an existing changeset

Publish (confirmed):

PATCH {BASE}/asset/changeset/1241/?tenant_id=447
{
  "status": "published"
}

Roll back (to confirm; the status name may differ):

PATCH {BASE}/asset/changeset/1241/?tenant_id=447
{
  "status": "rolled back"
}

Open a new changeset

POST {BASE}/asset/changeset/?tenant_id=447
{
  "tenant": 447,
  "name": "ORD design update 2026-11-20 14:30",
  "status": "work in progress"
}

Response: {"id": 1241, "status": "work in progress", ...}. Keep the id; every save in CDE-CALL-6 uses it.

Save updates and creates in an existing changeset

Update an existing asset (confirmed). Only the attributes sent are changed:

POST {BASE}/asset/asset_revision/?tenant_id=447
{
  "asset": 12345,
  "tenant": 447,
  "changeset": 1241,
  "attributes": {
    "Description": "Track section realigned",
    "Remarks": "Updated in ORD"
  }
}

Create a new asset (to confirm; same endpoint with no existing asset id, plus the class):

POST {BASE}/asset/asset_revision/?tenant_id=447
{
  "tenant": 447,
  "changeset": 1241,
  "asset_type": "TrackSection",
  "attributes": {
    "Name": "TS-0042",
    "Description": "New track section"
  }
}

Cancel / discard a changeset

There is no changeset delete. Discard by deleting each revision in the changeset (confirmed, owner only):

DELETE {BASE}/asset/asset_revision/98765/?tenant_id=447

Or roll the whole changeset back (to confirm), as in CDE-CALL-4.

Publish a changeset and get conflicts

PATCH {BASE}/asset/changeset/1241/?tenant_id=447
{
  "status": "published"
}

Response when the published data changed since the changeset was opened:

400
{
  "non_field_errors": ["Rebase required for 1 assets"]
}

The changeset stays work in progress. Read why:

GET {BASE}/asset/changeset/1241/?tenant_id=447
{
  "id": 1241,
  "status": "work in progress",
  "publish_failure_reason": "Failed published due to conflict",
  "conflicted_assets": 1
}

Conflicting attributes and resolution (confirmed)

Get the conflicting attributes for a revision:

GET {BASE}/asset/asset_revision/98765/rebase/?tenant_id=447
{
  "conflicts": [
    {"attribute_name": "Description"}
  ]
}

Then choose one resolution per conflicting asset:

Overwrite (keep your values):

POST {BASE}/asset/asset_revision/98765/rebase/keep_mine/?tenant_id=447

Auto-merge (returns 409 with conflicted_attributes when both users changed the same attribute):

POST {BASE}/asset/asset_revision/98765/rebase/auto_merge/?tenant_id=447

Revert (discard your change):

DELETE {BASE}/asset/asset_revision/98765/?tenant_id=447

After keep_mine or auto_merge, publish the changeset again (CDE-CALL-8).

Creating a Document

Upload a file

Step 1, get an upload URL. The blob name must follow the project naming convention:

POST {BASE}/core/sas_token/?blob_name=PRJ-ORD-DWG-0001_A.pdf&tenant_id=447

Response: a time-limited Azure Blob SAS URL and the blob key (name plus a unique suffix, e.g. PRJ-ORD-DWG-0001_A-5477c2d6.pdf).

Step 2, upload the file to the SAS URL (no ATLAS token; the URL carries the signature):

PUT {sas_url}
x-ms-blob-type: BlockBlob
Content-Type: application/pdf

<file bytes>

The Content-MD5 header of the response is the file hash used in CDE-CALL-11.

Create the Document object (confirmed, async)

POST {HOST}/aimsapi/assets/Document/create/
Authorization: Token <access_token>
{
  "contract": "CONTRACT-001",
  "class_code": "Document",
  "attribute": {
    "Document Number": "PRJ-ORD-DWG-0001",
    "Document Name": "Layout drawing, Sheet 1",
    "Revision": "A",
    "file_hash": "XrY7u+Ae7tCTyyK7j1rNww==",
    "isATLASserver": "true",
    "file": {
      "name": "PRJ-ORD-DWG-0001_A.pdf",
      "type": "application/pdf",
      "size": 482113,
      "key": "PRJ-ORD-DWG-0001_A-5477c2d6.pdf"
    }
  }
}

Response (the creation is queued, not finished):

{"result": "queued", "task_id": 8812}

Check task progress (confirmed)

GET {HOST}/aimsapi/task_service/tasks/?contract=CONTRACT-001&task_ids=8812
Authorization: Token <access_token>

Poll every few seconds until the status is no longer queued / in progress. On success the response includes the Document's tag_code:

{
  "results": [
    {"id": 8812, "status": "success", "tag_code": "1052a7f6-d2f7-46da-b501-d97b214d750f"}
  ]
}

(Field layout is abbreviated; the real task object has more fields.)

Link the Document to an asset

The link is an attribute on the asset (for example Documents), written as a new revision inside a changeset (CDE-CALL-5 first):

POST {BASE}/asset/asset_revision/?tenant_id=447
{
  "asset": 12345,
  "tenant": 447,
  "changeset": 1241,
  "attributes": {
    "Documents": [
      {"tag_code": "1052a7f6-d2f7-46da-b501-d97b214d750f"}
    ]
  }
}

The asset's class must define the attribute (Documents here). The same call works for a Switch, ETCSRequirement or ProjectVersion asset.