Transfer User Prompts Between Assistants
2 min read
Moving User Prompts Between Assistants
Using our GraphQL API, you can move user prompts from one assistant to another assistant either totally or for a subset of user prompts owned by specific users.
This documentation shows different use cases and scenarios of the API endpoint for transferring user prompts.
Authorization Requirements
To execute this mutation, the user must have the ADMIN_SPACE_WRITE role.
1. From one assistant to another assistant
The transfer of user prompts between assistants must involve both source and target assistants that are owned by the same company
Request
The
sourceAssistantIdis the ID of the assistant to move the prompts from.The
targetAssistantIdis the ID of the assistant to move the prompts to.
curl --location 'https://gateway.<baseUrl>/chat/graphql' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{ token }}' \
--data '{"query":"mutation TransferUserPrompt($src: String! $dest: String! $ownedBy: [String!]) {\n userPromptMoveManyToAssistant(\n sourceAssistantId: $src, \n targetAssistantId: $dest, \n ownedBy: $ownedBy\n ) {\n id\n companyId\n assistantId\n title\n prompt\n }\n}","variables":{"src":"{{ SourceAssistantId }}","dest":"{{ TargetAssistantId }}"}}'
Response
The returned response is a list of all the prompts that were successfully moved with their
assistantIdfield updated to thetargetAssistantIdthey were moved to.
{
"data": {
"userPromptMoveManyToAssistant": [
{
"id": "userPrompt_hpgczg8o8mej34xkc7wk3chn",
"assistantId": "{{ TargetAssistantId }}",
"title": "Prompt #3 - User - Owned Header",
"prompt": "Prompt #3 - User - Owned Body",
"ownedBy": "{{ UserID }}"
}
]
}
}
2. From one assistant to another assistant for prompts owned by specific users
The transfer of user prompts between assistants must involve both source and target assistants that are owned by the same company
Request
The
sourceAssistantIdis the ID of the assistant to move the prompts from.The
targetAssistantIdis the ID of the assistant to move the prompts to.The
ownedByis the optional list of user IDs that own the prompts that should be moved.
curl --location 'https://gateway.<baseUrl>/chat/graphql' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{ token }}' \
--data '{"query":"mutation TransferUserPrompt($src: String! $dest: String! $ownedBy: [String!]) {\n userPromptMoveManyToAssistant(\n sourceAssistantId: $src, \n targetAssistantId: $dest, \n ownedBy: $ownedBy\n ) {\n id\n companyId\n assistantId\n title\n prompt\n }\n}","variables":{"src":"{{ SourceAssistantId }}","dest":"{{ TargetAssistantId }}","ownedBy":["{{ UserID_1 }}","{{ UserID_2 }}"]}}'
Response
The returned response is a list of all the prompts that were successfully moved with their
assistantIdfield updated to thetargetAssistantIdthey were moved to.Only prompts owned by the specified users are moved between the source and target assistants.
{
"data": {
"userPromptMoveManyToAssistant": [
{
"id": "userPrompt_hpgczg8o8mej34xkc7wk4chn",
"assistantId": "{{ TargetAssistantId }}",
"title": "Prompt #4 - User1 - Owned Header",
"prompt": "Prompt #4 - User1 - Owned Body",
"ownedBy": "{{ UserID_1 }}"
},
{
"id": "userPrompt_hpgczg8o8mej34xkc7wk5chn",
"assistantId": "{{ TargetAssistantId }}",
"title": "Prompt #5 - User2 - Owned Header",
"prompt": "Prompt #5 - User2 - Owned Body",
"ownedBy": "{{ UserID_2 }}"
}
]
}
}
Copy User Prompts from One Assistant to Another
Maybe what you want to do is not to move the user prompts but create a copy of the user prompts on one assistant in another assistant; you can now achieve this using an additional copyOnly parameter in your request to the GraphQL userPromptMoveManyToAssistant mutation.
An example mutation could look like this:
mutation UserPromptCopyTest($sourceAssistantId: String!, $targetAssistantId: String!, $copyOnly: Boolean) {
userPromptMoveManyToAssistant(sourceAssistantId: $sourceAssistantId, targetAssistantId: $targetAssistantId, copyOnly: $copyOnly) {
id
title
prompt
assistantId
}
}With variables sets as such:
{
"sourceAssistantId": "<The assistant ID to copy from>",
"targetAssistantId": "<The assistant ID to copy to>",
"copyOnly": true
}cURL example
curl --location 'https://gateway.qa.unique.app/chat-gen2/graphql' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{ token }}' \
--data '{"query":"mutation UserPromptCopyTest($sourceAssistantId: String!, $targetAssistantId: String!, $copyOnly: Boolean) {\n userPromptMoveManyToAssistant(sourceAssistantId: $sourceAssistantId, targetAssistantId: $targetAssistantId, copyOnly: $copyOnly) {\n id\n title\n prompt\n assistantId\n }\n}","variables":{"sourceAssistantId":"<Assistant ID to copy from>","targetAssistantId":"<Assistant ID to copy to>","copyOnly":true}}'Setting copyOnly to true ensures that a new copy of the prompts is made and source assistant retains its existing user prompts.