List the components a project has synced
List the components a project has synced to Studio, with their props, from a script. You need this to check what the component service holds for a project, such as after you run csdx studio:component:sync.
The example is the Blog project and its BlogBody and PostCard components. BlogBody has the type blog-body and no display name.
Prerequisites
- The project's UID. The example is Blog,
0123456789abcdef01234567. To find a UID, see List and read projects. - Read access to the project's stack.
- A credential and your organization UID. Send an
authtokensession token or anauthorization: BearerOAuth access token, and theorganization_uidheader. The example's organization UID isblt2222222222222222. The curl command on this page reads an OAuth access token fromCS_ACCESS_TOKEN. See Headers every call needs. - A component synced with
csdx studio:component:sync. A project with nothing synced answers with an empty list, not an error.
What this is and what you get
Three things get called a registered component, and the list holds only one of them. Say the Blog app registers BlogBody and PostCard, and you've synced PostCard.
| Kind | What it means | In this list |
|---|---|---|
| Registered in code | Your app registers the component, such as BlogBody with the type blog-body. | No |
| Visible in the palette | The palette offers it. The palette keys on the type string your app registers. | No |
| Synced to the service | You ran csdx studio:component:sync on its file. The component service keeps a record of it and its props. | Yes |
BlogBody is registered in code and has never been synced, so it isn't in the list. PostCard is synced, so it is. A component you register in code but never sync doesn't appear.
csdx studio:component:sync is the only released command that writes to this list. No released command or API route removes a synced component. The command takes one required flag, --component-path (-p), the file to sync.
csdx studio:component:sync --component-path=src/components/PostCard.tsx
It registers each component it finds in the file, and it records the version 1.0.0 for each one. Syncing also makes your code components available in the Figma plugin for component mapping. See Push your code into Studio.
The list doesn't return the type string you passed to registerComponent, such as blog-body for BlogBody. A node's type in ui is the type string your app registers. See Register a component.
You get one item for each synced component, with its props.
List the components a project has synced
To list the components, send GET to the project's registered-components path. This row comes from the Registered components route table.
| Method | Path | What it does |
|---|---|---|
GET | /v1/projects/{projectUid}/registered-components | Lists the components synced to the project with csdx studio:component:sync, with their props. The route is read-only. |
For Blog, send the request with the project UID in the path.
curl "https://composable-studio-api.contentstack.com/v1/projects/0123456789abcdef01234567/registered-components" \
-H "authorization: Bearer $CS_ACCESS_TOKEN" \
-H "organization_uid: blt2222222222222222"
The route takes no query parameters. It returns every synced component at once.
The API answers 200 with registered_components and meta.count. Blog has one synced component, PostCard, so registered_components has one item and meta.count is 1. After you sync BlogBody too, meta.count is 2.
Each item carries uid, organization_uid, projectId, componentName, displayName, description, aiDescription, version, importPath, createdAt, updatedAt and props. These rows come from the full table of fields under Registered components route.
| Component field | What it holds |
|---|---|
projectId | The project UID. |
description, aiDescription | Descriptions for people and for AI tools. Either can be empty. |
version | The version recorded at sync. |
props | The component's props. Each has type and name, and can have displayName, description, placeholder and defaultValue. |
If it doesn't work
- The list is empty, or a component you registered is missing. You haven't synced it. A project with nothing synced answers
200with{ "registered_components": [], "meta": { "count": 0 } }. Runcsdx studio:component:syncon the component's file. 401with error code48. Neither anauthtokennor anauthorization: Bearertoken reached the API.404with error code1. No project with that UID in your organization. A deleted project answers the same way.422with error code21. Your token can't read the project's connected stack.- Error code
46, with a4xxstatus or502. The component service refused the call. A403or other client error keeps its status. A502means the component service didn't answer, failed, or sent something other than a list.
Where to go next:
- Place a component in a layout: Composition JSON.
- Look up every route and field: API endpoints. Look up every error code: API errors and validation.
- Sync another component: CLI commands.