Create a workspace¶
Create a workspace on behalf of the current identity and return the new workspace ID.
POST https://moi.matrixorigin.cn/newmoi/workspaces
Before you call this API¶
Choose a name for the new workspace. Prepare a personal access token and the name.
The following example uses:
$AI_STUDIO_API_KEY: Your personal access token, passed in theX-API-Keyheader.$WORKSPACE_NAME: The name of the workspace to create, passed in the request body’snamefield.
A workspace name cannot be empty. The service ignores leading and trailing whitespace in the name.
Request example¶
curl -X POST "https://moi.matrixorigin.cn/newmoi/workspaces" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "'$WORKSPACE_NAME'"
}'
Request body¶
Parameter |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
Name of the workspace to create. |
Successful response¶
On success, the API returns 200. data.id is the new workspace ID.
{
"code": "OK",
"msg": "OK",
"data": {
"id": "ws_01"
}
}
Response fields:
Field |
Type |
Description |
|---|---|---|
|
string |
|
|
string |
|
|
string |
ID of the new workspace. |
Error response¶
{
"code": "ErrWorkspaceAlreadyExists",
"msg": "Workspace already exists",
"data": null
}
Common HTTP errors¶
HTTP status |
Error code |
Common cause |
Recommended action |
|---|---|---|---|
|
|
|
Provide a non-empty workspace name and retry. |
|
|
Credentials are missing or invalid. |
Check the personal access token. |
|
|
The current identity has not been synchronized or cannot create workspaces. |
Complete account synchronization, or ask an administrator for access before retrying. |
|
|
A workspace with the same name is being created or already exists. |
Wait for the pending creation to finish, or use another name. |
|
|
An earlier creation was rolled back. |
Check the creation conditions and retry with a new request. |
|
|
The service could not create the workspace. |
Record the request time and error message, then contact an administrator. |