Skip to content
Verified

List projects and deployments

Every workspace an account owns, then every app actually running, as two CouchDB view reads.

"Projects" and "deployments" answer two different questions. A project is a workspace on the account, the thing you would see in the project switcher, whether or not anything inside it has ever gone live. A deployment is one app that is actually running somewhere, is_deployment: true on its own document. Listing an account usually means both: the workspaces first, then what each one has running.

Methods

POST/cpi/get_account_projects
user

Get Account Projects

Returns the projects owned by the account (or all projects for superuser and support accounts) from the user_projects master view.

POST/cpi/get_account_deployments
user

Get Account Deployments

Returns the deployments associated with the account from the user_deployments master view.

Walkthrough

List the account's projects

No fields beyond your key: both methods key the CouchDB view off the uid your credential already resolves to.

curl -s https://xuda.ai/cpi/get_account_projects \
  -H 'content-type: application/json' \
  -d '{"api_key":"YOUR_API_KEY"}'
const res = await fetch('https://xuda.ai/cpi/get_account_projects', {
  method: 'POST',
  headers: { 'content-type': 'application/json' },
  body: JSON.stringify({ api_key: 'YOUR_API_KEY' }),
});
const { code, data } = await res.json();
if (code > 0) {
  for (const row of data.rows) console.log(row.id, row.value.app_name, row.value.app_status_code);
}
import requests

res = requests.post(
    'https://xuda.ai/cpi/get_account_projects',
    json={'api_key': 'YOUR_API_KEY'},
)
body = res.json()
if body['code'] > 0:
    for row in body['data']['rows']:
        print(row['id'], row['value']['app_name'], row['value']['app_status_code'])

2. List what is actually deployed

Same shape, a different view: user_deployments only emits a document when is_deployment is true, so this list is a subset of every app the account has ever created, the ones with a live access URL.

curl -s https://xuda.ai/cpi/get_account_deployments \
  -H 'content-type: application/json' \
  -d '{"api_key":"YOUR_API_KEY"}'
const res = await fetch('https://xuda.ai/cpi/get_account_deployments', {
  method: 'POST',
  headers: { 'content-type': 'application/json' },
  body: JSON.stringify({ api_key: 'YOUR_API_KEY' }),
});
const { code, data } = await res.json();
if (code > 0) {
  for (const row of data.rows) console.log(row.id, row.value.app_hosting, row.value.app_status_code);
}
import requests

res = requests.post(
    'https://xuda.ai/cpi/get_account_deployments',
    json={'api_key': 'YOUR_API_KEY'},
)
body = res.json()
if body['code'] > 0:
    for row in body['data']['rows']:
        print(row['id'], row['value']['app_hosting'], row['value']['app_status_code'])

The response

Both methods pass a CouchDB view result straight through, unwrapped: code is 871 (the fixed success code get_couch_view always returns, not the usual 1), and data is the raw nano view answer, total_rows, offset and a rows array of { id, key, value }. id is the project's (or deployment's) _id, the value you pass as app_id to every other call in this section.

json
{
  "code": 871,
  "data": {
    "total_rows": 3,
    "offset": 0,
    "rows": [
      {
        "id": "app_5d9e21",
        "key": "acc_8f2a1c",
        "value": {
          "_id": "app_5d9e21",
          "app_name": "Marketing site",
          "app_type": "master",
          "app_status_code": 3,
          "app_access_type": "private",
          "docDate": 1735689600000,
          "app_icon_prop": { "app_icon_background_color": "#4f46e5", "app_icon_size": "md" }
        }
      }
    ]
  }
}

get_account_deployments rows carry the same fields plus app_hosting_server, app_datacenter_id, app_hosting and is_deployment: true, since user_deployments emits those on top of the shared set. app_status_code < 4 is the only status this view or user_projects will ever show you: both map functions filter out anything at 4 or above, so a deleted project simply stops appearing rather than showing up with a status to check.

A workspace's row can carry a name override

get_account_projects stamps main_profile_name onto the account's own workspace row when that workspace has a named profile, so the row you show as "your" project can read differently from its stored app_name. Prefer main_profile_name when present.

Errors

Both methods only ever fail the way every call can: a missing or unauthorized api_key (-401, see Errors). Neither one branches on app_id or any other input, since neither takes one, an empty rows array is a real, successful answer for an account with nothing in that list yet, not an error.

Next