Create store clone

Starts a store clone inside the caller's multi-retailer group, or replays the one that already exists for the same Idempotency-Key.

What the new store gets

  • Plan and franchise are inherited from the source store (sourceRetailerId). Any plan, price or franchise field in the body is discarded.
  • Name, CNPJ, address and phone come from the body. They are never copied from the source store. The CNPJ is required and must not belong to another store of the platform.
  • One store per CNPJ: the first request of a key reserves the CNPJ for its operation with a conditional write. While another clone of the same CNPJ is alive (or created its store), the answer is 422 with TAX_DOCUMENT_ID_ALREADY_REGISTERED on taxDocumentId. A reservation whose operation never got claimed, or whose sign-up failed for good before creating a store, is taken over. The signUp step checks the CNPJ against the platform again right before the sign-up and fails for good with TAX_DOCUMENT_ID_ALREADY_REGISTERED when another store got it meanwhile.
  • Duplicating copies only the configurations the person checked in copyItems, by category (SETTINGS, FEATURES, BUSINESS_HOURS, DISPATCH_LIMIT). The configuration engine says which keys belong to each category. An empty list creates the store from scratch.
  • The single store has no manager and no email is sent: the login of the caller is linked to the new store and is its first access. A managerEmail in the body is discarded.
  • The sign-up identity (email, password and admin name) is generated by the server. The temporary admin user is disabled once the store is provisioned, and the login of the caller is linked to the new store.

Access
Needs an admin session (API users are refused), the multi-retailer-login and store-clone flags active for the caller's retailer, and a caller registered with a groupId. The retailer of the caller must be the MAIN contract of its group and the source store must belong to that group. The admin master may duplicate any store of the group; any other caller only the current store or one of the caller's multi-login stores. When any check fails the answer is 403. With the store-clone flag off, this route answers 403.

Idempotency
The Idempotency-Key becomes the operationId (in lower case). Repeating the call with the same key and the same body returns the current state and runs only the steps not concluded yet. The same key with a different sourceRetailerId, mode, copyItems or store data answers 409. A key already seen skips the field validation, so 422 happens only the first time a key is used.

Result
The call runs the pending steps in order. It stops when all are concluded, when a step fails or is blocked, or when the time budget of the request is nearly out: a step only starts with at least 5 s of budget left, and a step cut by the budget asks to continue later instead of failing.

  • 201: at least one step ran and the operation is completed.
  • 200: no step ran. The operation was already completed or is stopped at a step that failed for good.
  • 202: the time budget ran out. The body has nextAction: RESUME. Call POST /retailers/clones/{operationId}/resume.
  • 207: at least one step ran and a step is FAILED or BLOCKED.

A schema violation, an invalid JSON body or a missing or malformed Idempotency-Key answers 400. The 400 of a schema violation carries the list of violations as the body.

Recent Requests
Log in to see full request history
TimeStatusUser Agent
Retrieving recent requests…
LoadingLoading…
Body Params

Request to create one store, from scratch or duplicating a store.
The request schema checks sourceRetailerId, mode, copyItems and taxDocumentId (400). A missing or blank taxDocumentId is answered with 400 and the message Informe o CNPJ da loja.. At least one of mode and copyItems is required.
The other store fields are checked by the validation rules: a problem is answered with 422 and one fieldErrors item per field, each with field, code and a pt-BR message.
Field error codes: REQUIRED, INVALID_TAX_DOCUMENT_ID, TAX_DOCUMENT_ID_ALREADY_REGISTERED, REJECTED_BY_PLATFORM, SOURCE_NOT_COPYABLE.
"Duplicate a store" sends the checked items in copyItems with that store as sourceRetailerId. "Create from scratch" sends copyItems: [] (or mode: SHELL_ONLY) with the current store as sourceRetailerId.
The single store has no manager: the caller becomes the first user of the new store. A managerEmail sent here is discarded; only the spreadsheet has a manager.
Fields not listed here are discarded. That includes any plan, price or franchise value, because the new store always inherits plan and franchise from the source store.

string
required

ID of the store that plan and franchise are copied from. It must belong to the caller's group. The admin master may pick any store of the group; any other caller only the current store or one of the caller's multi-login stores, otherwise 403.

copyItems
array of strings, unique

Categories of the source store configuration the person checked to copy. The configuration engine (retailer-config-api) files every key under one category in GET /group-config/keys ({ configKey, category }), and only the keys of the checked categories are copied.
Today SETTINGS (Store settings) covers the store details, customer registration, custom fields, sales pipelines and sales channels; FEATURES the Features tab; BUSINESS_HOURS the store hours and the automatic logout; DISPATCH_LIMIT the dispatch limit.
A checked category the engine does not list is not copied and shows up in the configuration step as ignored, with reason categoryNotListedByEngine; it does not fail the store.
A key whose change the engine refuses with 403 (for example marketing.dispatchLimit@v2 when the caller lacks the usage-limit permission) is not copied either and shows up in the configuration step as ignored, with reason changeNotAllowed; the other keys are still copied and the store does not fail.
An empty list creates the store from scratch (SHELL_ONLY). Any other value, such as USAGE_LIMITS, answers 400.
When mode is also sent, it must agree with the list, otherwise 400 with the message O modo não combina com os itens marcados para copiar.. When only mode is sent, WITH_CONFIGURATION means every item and SHELL_ONLY means none.

string
enum

Kept for older clients; prefer copyItems.
SHELL_ONLY creates the store, its contract and the login link, and skips the configuration copy.
WITH_CONFIGURATION also copies the configuration of the source store. GET /retailers/clones/capabilities offers it only while the store-clone-with-configuration flag is active for the caller's retailer.

Allowed:
string
required

Name of the new store, typed by the person. It is checked for availability in parse-server (422 on retailerName).

string
required

Street of the new store. Never copied from the source store.

string
required

Street number of the new store. Never copied from the source store.

string
required

Suburb of the new store. Required. Never copied from the source store.

string
required

Zip code of the new store. Never copied from the source store.

string
required

City of the new store. Never copied from the source store.

string
required

State of the new store. Never copied from the source store.

string

Optional host name of the new store. When sent, it is checked for availability in parse-server (422 on hostName).

string

Optional phone of the new store. Never copied from the source store.

string

Optional address complement. Never copied from the source store.

string

Optional country of the new store.

string
required

CNPJ of the new store, with or without the mask. Required. It must have valid check digits (INVALID_TAX_DOCUMENT_ID) and must not belong to another store of the platform nor to another clone in progress (TAX_DOCUMENT_ID_ALREADY_REGISTERED).

string

Optional business name used on invoices of the new store.

Headers
string
required
length between 8 and 64
^[A-Za-z0-9._-]{8,64}$

Key that identifies this clone. From 8 to 64 characters, only letters, digits, dots, hyphens and underscores (^[A-Za-z0-9._-]{8,64}$).
It is not case sensitive: the server keeps it in lower case and returns it as operationId. Use a new random value for each new clone, and reuse the same value to retry it.

Responses

Language
Credentials
Header
URL
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json