productArchive
Required scope: edit_products
Irreversible action
Archiving a product is permanent. Once archived, the product cannot be restored. If you only need to temporarily remove a product from use, consider productDisable instead.
Permanently archive a product. The product transitions to ARCHIVED status and can no longer be modified or used in new orders.
Mutation
graphql
mutation ProductArchive($id: String!) {
productArchive(id: $id) {
id
status
}
}Arguments
| Argument | Type | Description |
|---|---|---|
id | String! | The product UUID to archive |
Example
Variables
json
{
"id": "prod_456"
}Response
json
{
"data": {
"productArchive": {
"id": "prod_456",
"status": "ARCHIVED"
}
}
}Code Examples
bash
curl -X POST https://api-v3.happycolis.com/graphql \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"query": "mutation ProductArchive($id: String!) { productArchive(id: $id) { id status } }",
"variables": {
"id": "prod_456"
}
}'js
async function archiveProduct(accessToken, productId) {
const response = await fetch('https://api-v3.happycolis.com/graphql', {
method: 'POST',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: `
mutation ProductArchive($id: String!) {
productArchive(id: $id) {
id
status
}
}
`,
variables: { id: productId },
}),
});
const { data, errors } = await response.json();
if (errors) throw new Error(errors[0].message);
return data.productArchive;
}
// Usage
const product = await archiveProduct(accessToken, 'prod_456');python
import requests
def archive_product(access_token, product_id):
response = requests.post(
'https://api-v3.happycolis.com/graphql',
headers={
'Authorization': f'Bearer {access_token}',
'Content-Type': 'application/json',
},
json={
'query': '''
mutation ProductArchive($id: String!) {
productArchive(id: $id) {
id
status
}
}
''',
'variables': {'id': product_id},
},
)
result = response.json()
if 'errors' in result:
raise Exception(result['errors'][0]['message'])
return result['data']['productArchive']
# Usage
product = archive_product(access_token, 'prod_456')php
function archiveProduct(string $accessToken, string $productId): array
{
$client = new \GuzzleHttp\Client();
$response = $client->post('https://api-v3.happycolis.com/graphql', [
'headers' => [
'Authorization' => 'Bearer ' . $accessToken,
'Content-Type' => 'application/json',
],
'json' => [
'query' => '
mutation ProductArchive($id: String!) {
productArchive(id: $id) {
id
status
}
}
',
'variables' => ['id' => $productId],
],
]);
$result = json_decode($response->getBody()->getContents(), true);
if (isset($result['errors'])) {
throw new \Exception($result['errors'][0]['message']);
}
return $result['data']['productArchive'];
}
// Usage
$product = archiveProduct($accessToken, 'prod_456');go
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
func archiveProduct(accessToken, productID string) (map[string]interface{}, error) {
query := `
mutation ProductArchive($id: String!) {
productArchive(id: $id) {
id
status
}
}
`
body, _ := json.Marshal(map[string]interface{}{
"query": query,
"variables": map[string]interface{}{"id": productID},
})
req, _ := http.NewRequest("POST", "https://api-v3.happycolis.com/graphql", bytes.NewBuffer(body))
req.Header.Set("Authorization", "Bearer "+accessToken)
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
if errs, ok := result["errors"]; ok {
return nil, fmt.Errorf("graphql error: %v", errs)
}
data := result["data"].(map[string]interface{})
return data["productArchive"].(map[string]interface{}), nil
}