Create or Upsert Metafield
curl --request POST \
--url https://api.launchmystore.io/api/v1/metafields.json \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"namespace": "<string>",
"key": "<string>",
"type": "<string>",
"value": "<any>",
"ownerType": "<string>",
"ownerId": "<string>"
}
'import requests
url = "https://api.launchmystore.io/api/v1/metafields.json"
payload = {
"namespace": "<string>",
"key": "<string>",
"type": "<string>",
"value": "<any>",
"ownerType": "<string>",
"ownerId": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
namespace: '<string>',
key: '<string>',
type: '<string>',
value: '<any>',
ownerType: '<string>',
ownerId: '<string>'
})
};
fetch('https://api.launchmystore.io/api/v1/metafields.json', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.launchmystore.io/api/v1/metafields.json",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'namespace' => '<string>',
'key' => '<string>',
'type' => '<string>',
'value' => '<any>',
'ownerType' => '<string>',
'ownerId' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.launchmystore.io/api/v1/metafields.json"
payload := strings.NewReader("{\n \"namespace\": \"<string>\",\n \"key\": \"<string>\",\n \"type\": \"<string>\",\n \"value\": \"<any>\",\n \"ownerType\": \"<string>\",\n \"ownerId\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.launchmystore.io/api/v1/metafields.json")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"namespace\": \"<string>\",\n \"key\": \"<string>\",\n \"type\": \"<string>\",\n \"value\": \"<any>\",\n \"ownerType\": \"<string>\",\n \"ownerId\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.launchmystore.io/api/v1/metafields.json")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"namespace\": \"<string>\",\n \"key\": \"<string>\",\n \"type\": \"<string>\",\n \"value\": \"<any>\",\n \"ownerType\": \"<string>\",\n \"ownerId\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"status": 123,
"state": "<string>",
"data.metafield": {}
}Metafields
Create or Upsert Metafield
Create a new metafield, or update if one already exists for the same owner+namespace+key
POST
/
api
/
v1
/
metafields.json
Create or Upsert Metafield
curl --request POST \
--url https://api.launchmystore.io/api/v1/metafields.json \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"namespace": "<string>",
"key": "<string>",
"type": "<string>",
"value": "<any>",
"ownerType": "<string>",
"ownerId": "<string>"
}
'import requests
url = "https://api.launchmystore.io/api/v1/metafields.json"
payload = {
"namespace": "<string>",
"key": "<string>",
"type": "<string>",
"value": "<any>",
"ownerType": "<string>",
"ownerId": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
namespace: '<string>',
key: '<string>',
type: '<string>',
value: '<any>',
ownerType: '<string>',
ownerId: '<string>'
})
};
fetch('https://api.launchmystore.io/api/v1/metafields.json', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.launchmystore.io/api/v1/metafields.json",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'namespace' => '<string>',
'key' => '<string>',
'type' => '<string>',
'value' => '<any>',
'ownerType' => '<string>',
'ownerId' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.launchmystore.io/api/v1/metafields.json"
payload := strings.NewReader("{\n \"namespace\": \"<string>\",\n \"key\": \"<string>\",\n \"type\": \"<string>\",\n \"value\": \"<any>\",\n \"ownerType\": \"<string>\",\n \"ownerId\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.launchmystore.io/api/v1/metafields.json")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"namespace\": \"<string>\",\n \"key\": \"<string>\",\n \"type\": \"<string>\",\n \"value\": \"<any>\",\n \"ownerType\": \"<string>\",\n \"ownerId\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.launchmystore.io/api/v1/metafields.json")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"namespace\": \"<string>\",\n \"key\": \"<string>\",\n \"type\": \"<string>\",\n \"value\": \"<any>\",\n \"ownerType\": \"<string>\",\n \"ownerId\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"status": 123,
"state": "<string>",
"data.metafield": {}
}Create or Upsert Metafield
This endpoint upserts: if a metafield with the same(ownerType, ownerId, namespace, key) already exists and your app owns it,
its value is updated; otherwise a new metafield is created. There is at most
one metafield per (resource, namespace, key).
The body can be flat or wrapped in { "metafield": { ... } }.
Request
curl -X POST "https://api.launchmystore.io/api/v1/metafields.json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"metafield": {
"namespace": "$app",
"key": "warranty_years",
"type": "number_integer",
"value": 5,
"ownerType": "product",
"ownerId": "482910"
}
}'
const response = await fetch('https://api.launchmystore.io/api/v1/metafields.json', {
method: 'POST',
headers: {
Authorization: `Bearer ${accessToken}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
metafield: {
namespace: '$app',
key: 'warranty_years',
type: 'number_integer',
value: 5,
ownerType: 'product',
ownerId: '482910',
},
}),
});
Required scope
write_metafields
Body parameters
Your app’s namespace:
$app (stored as app--<your app id>),
$app:<suffix>, app_<your_handle> (e.g. app_loyalty_engine), or a
namespace your app created. Writing to a namespace that belongs to the
merchant (e.g. custom) or to another app is refused with 403 — see
Namespaces and ownership.Any metafield type from the
type catalogue —
single_line_text_field, number_integer, json, money,
product_reference, … — including list.<type> (e.g.
list.single_line_text_field). Also string (free text). If omitted, the
existing metafield’s type, then the field definition’s type, then string
is used. An unknown type is rejected with 422.The value, validated against
type (and against the field definition’s
validations when one exists) — an invalid value is rejected with 422.
Scalars are sent as-is (string, number, boolean). Compound types
(weight, dimension, volume, money, rating, lists, JSON) are sent
as JSON. json values may also be sent pre-serialized as a string; they
are stored as sent.
An empty string is rejected with 422. To represent “nothing
selected”, delete the metafield or store
an explicit sentinel (e.g. "*").One of
shop, product, variant, collection, customer, order,
page, blog, article, cart. Lowercase only. owner_resource is
accepted as an alias.The id of the owning resource. Required for every owner type except
shop, where it defaults to the store. For product, variant and
collection either id form works (numeric id or UUID); the metafield is
stored under the UUID, which is what the storefront reads. owner_id is
accepted as an alias.Examples by type
Scalar text
{
"namespace": "$app",
"key": "badge",
"type": "single_line_text_field",
"value": "BESTSELLER",
"ownerType": "product",
"ownerId": "..."
}
Boolean
{
"namespace": "$app",
"key": "is_featured",
"type": "boolean",
"value": true,
"ownerType": "product",
"ownerId": "..."
}
Rich text (HTML, rendered unescaped in Aqua)
{
"namespace": "$app",
"key": "care_instructions",
"type": "rich_text_field",
"value": "<p>Hand wash only.</p>",
"ownerType": "product",
"ownerId": "..."
}
Measurement
{
"namespace": "$app",
"key": "weight",
"type": "weight",
"value": { "unit": "KILOGRAMS", "value": 1.2 },
"ownerType": "product",
"ownerId": "..."
}
Money
{
"namespace": "$app",
"key": "deposit",
"type": "money",
"value": { "amount": "12.50", "currency_code": "USD" },
"ownerType": "product",
"ownerId": "..."
}
Reference
{
"namespace": "$app",
"key": "matching_product",
"type": "product_reference",
"value": "8b3e2c10-...",
"ownerType": "product",
"ownerId": "..."
}
List
{
"namespace": "$app",
"key": "tags",
"type": "list.single_line_text_field",
"value": ["red", "limited", "sale"],
"ownerType": "product",
"ownerId": "..."
}
Shop-level app settings
{
"namespace": "$app",
"key": "config",
"type": "json",
"value": { "enabled": true, "threshold": 50 },
"ownerType": "shop"
}
Response
The response is the standard envelope. On success the created/updated metafield is returned underdata.metafield.
Example response
{
"status": 201,
"state": "success",
"message": null,
"data": {
"metafield": {
"id": "e607f43e-9251-451e-a45c-38bf28d61154",
"metafieldId": "e607f43e-9251-451e-a45c-38bf28d61154",
"namespace": "app--3f2a9c1e-...",
"key": "warranty_years",
"value": "5",
"type": "number_integer",
"ownerType": "product",
"ownerId": "e5f6a7b8-9c0d-4e1f-a2b3-c4d5e6f7a8b9",
"appId": "3f2a9c1e-...",
"createdAt": "2026-05-09T13:32:53.135Z",
"updatedAt": "2026-05-09T13:32:53.135Z"
}
},
"count": null,
"pagination": null
}
Cache invalidation
A successful upsert automatically expires the cached copy of the owning resource and any cached page HTML that rendered it. The next storefront render sees the new value.Error codes
| Status | Description |
|---|---|
400 | A required field is missing (namespace, key, value, ownerType, or ownerId for non-shop owners) |
401 | Invalid or missing access token |
403 | Missing write_metafields scope, or the namespace / metafield belongs to the merchant or another app |
422 | Unknown type, or a value that is not valid for it (message says why) |