Create variant
curl --request POST \
--url https://api.ya.onl/v1/products/{product_id}/variants \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"name": "Polo Negro - Talla M",
"base_price": 49.9,
"currency": "PEN",
"option_values": [
10,
25
],
"sku": "POL-NEG-M-001",
"status": "available"
}
'import requests
url = "https://api.ya.onl/v1/products/{product_id}/variants"
payload = {
"name": "Polo Negro - Talla M",
"base_price": 49.9,
"currency": "PEN",
"option_values": [10, 25],
"sku": "POL-NEG-M-001",
"status": "available"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Polo Negro - Talla M',
base_price: 49.9,
currency: 'PEN',
option_values: [10, 25],
sku: 'POL-NEG-M-001',
status: 'available'
})
};
fetch('https://api.ya.onl/v1/products/{product_id}/variants', 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.ya.onl/v1/products/{product_id}/variants",
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([
'name' => 'Polo Negro - Talla M',
'base_price' => 49.9,
'currency' => 'PEN',
'option_values' => [
10,
25
],
'sku' => 'POL-NEG-M-001',
'status' => 'available'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$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.ya.onl/v1/products/{product_id}/variants"
payload := strings.NewReader("{\n \"name\": \"Polo Negro - Talla M\",\n \"base_price\": 49.9,\n \"currency\": \"PEN\",\n \"option_values\": [\n 10,\n 25\n ],\n \"sku\": \"POL-NEG-M-001\",\n \"status\": \"available\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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.ya.onl/v1/products/{product_id}/variants")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Polo Negro - Talla M\",\n \"base_price\": 49.9,\n \"currency\": \"PEN\",\n \"option_values\": [\n 10,\n 25\n ],\n \"sku\": \"POL-NEG-M-001\",\n \"status\": \"available\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ya.onl/v1/products/{product_id}/variants")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Polo Negro - Talla M\",\n \"base_price\": 49.9,\n \"currency\": \"PEN\",\n \"option_values\": [\n 10,\n 25\n ],\n \"sku\": \"POL-NEG-M-001\",\n \"status\": \"available\"\n}"
response = http.request(request)
puts response.read_body{
"id": 123,
"name": "<string>",
"base_price": "<string>",
"currency": "<string>",
"status": "<string>",
"sku": "<string>"
}{
"type": "<string>",
"detail": "<string>"
}{
"type": "<string>",
"detail": "<string>"
}{
"type": "<string>",
"detail": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}{
"type": "<string>",
"detail": "<string>"
}Variants
Create variant
Add a new variant to an existing product.
POST
/
v1
/
products
/
{product_id}
/
variants
Create variant
curl --request POST \
--url https://api.ya.onl/v1/products/{product_id}/variants \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"name": "Polo Negro - Talla M",
"base_price": 49.9,
"currency": "PEN",
"option_values": [
10,
25
],
"sku": "POL-NEG-M-001",
"status": "available"
}
'import requests
url = "https://api.ya.onl/v1/products/{product_id}/variants"
payload = {
"name": "Polo Negro - Talla M",
"base_price": 49.9,
"currency": "PEN",
"option_values": [10, 25],
"sku": "POL-NEG-M-001",
"status": "available"
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Polo Negro - Talla M',
base_price: 49.9,
currency: 'PEN',
option_values: [10, 25],
sku: 'POL-NEG-M-001',
status: 'available'
})
};
fetch('https://api.ya.onl/v1/products/{product_id}/variants', 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.ya.onl/v1/products/{product_id}/variants",
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([
'name' => 'Polo Negro - Talla M',
'base_price' => 49.9,
'currency' => 'PEN',
'option_values' => [
10,
25
],
'sku' => 'POL-NEG-M-001',
'status' => 'available'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$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.ya.onl/v1/products/{product_id}/variants"
payload := strings.NewReader("{\n \"name\": \"Polo Negro - Talla M\",\n \"base_price\": 49.9,\n \"currency\": \"PEN\",\n \"option_values\": [\n 10,\n 25\n ],\n \"sku\": \"POL-NEG-M-001\",\n \"status\": \"available\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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.ya.onl/v1/products/{product_id}/variants")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Polo Negro - Talla M\",\n \"base_price\": 49.9,\n \"currency\": \"PEN\",\n \"option_values\": [\n 10,\n 25\n ],\n \"sku\": \"POL-NEG-M-001\",\n \"status\": \"available\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ya.onl/v1/products/{product_id}/variants")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Polo Negro - Talla M\",\n \"base_price\": 49.9,\n \"currency\": \"PEN\",\n \"option_values\": [\n 10,\n 25\n ],\n \"sku\": \"POL-NEG-M-001\",\n \"status\": \"available\"\n}"
response = http.request(request)
puts response.read_body{
"id": 123,
"name": "<string>",
"base_price": "<string>",
"currency": "<string>",
"status": "<string>",
"sku": "<string>"
}{
"type": "<string>",
"detail": "<string>"
}{
"type": "<string>",
"detail": "<string>"
}{
"type": "<string>",
"detail": "<string>"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}{
"type": "<string>",
"detail": "<string>"
}Autorizaciones
Merchant API key for authentication
Parámetros de ruta
Product identifier
Cuerpo
application/json
Variant display name
Required string length:
1 - 250Ejemplo:
"Polo Negro - Talla M"
Original price before discounts
Rango requerido:
x >= 0Ejemplo:
49.9
Currency code (ISO 4217)
Opciones disponibles:
MXN, PEN, COP, CLP, ARS, BRL, VES, BOB, USD, PYG, UYU, CRC, EUR, GTQ Ejemplo:
"PEN"
List of option value IDs to associate with this variant. These IDs are returned when creating options via POST /products/{product_id}/options. At least one option value is required.
Minimum array length:
1Ejemplo:
[10, 25]
Product variant SKU code
Maximum string length:
100Ejemplo:
"POL-NEG-M-001"
Variant availability status
Opciones disponibles:
not_available, available Respuesta
Successful Response
Unique variant identifier
Variant display name
Original price before discounts
Pattern:
^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$Currency code (ISO 4217)
Variant availability status
Product variant SKU code

