Stores
Create a store
Create a unique OpenFGA store which is used to store authorization models and relationship tuples.
POST
/
stores
Node.js
const { OpenFgaClient, ConsistencyPreference } = require('@openfga/sdk');
const fgaClient = new OpenFgaClient({
apiUrl: process.env.FGA_API_URL,
});
async function main() {
const body = {
"name": "FGA Demo Store"
};
const response = await fgaClient.createStore(body);
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});package main
import (
"context"
"os"
. "github.com/openfga/go-sdk/client"
)
func main() {
fgaClient, err := NewSdkClient(&ClientConfiguration{
ApiUrl: os.Getenv("FGA_API_URL"),
})
if err != nil {
panic(err)
}
body := ClientCreateStoreRequest{
Name: "FGA Demo Store",
}
data, err := fgaClient.CreateStore(context.Background()).Body(body).Execute()
if err != nil {
panic(err)
}
_ = data
}using System.Collections.Generic;
using OpenFga.Sdk.Client;
using OpenFga.Sdk.Client.Model;
using OpenFga.Sdk.Model;
using Environment = System.Environment;
var fgaClient = new OpenFgaClient(new ClientConfiguration() {
ApiUrl = Environment.GetEnvironmentVariable("FGA_API_URL"),
});
var body = new ClientCreateStoreRequest {
Name = "FGA Demo Store",
};
var response = await fgaClient.CreateStore(body);import asyncio
import os
from openfga_sdk.client import OpenFgaClient, ClientConfiguration
from openfga_sdk.models import CreateStoreRequest
async def main():
configuration = ClientConfiguration(
api_url=os.environ.get("FGA_API_URL"),
)
async with OpenFgaClient(configuration) as fga_client:
body = CreateStoreRequest(
name="FGA Demo Store",
)
response = await fga_client.create_store(body)
asyncio.run(main())import dev.openfga.sdk.api.client.OpenFgaClient;
import dev.openfga.sdk.api.configuration.ClientConfiguration;
import dev.openfga.sdk.api.configuration.*;
import dev.openfga.sdk.api.client.model.*;
import dev.openfga.sdk.api.model.*;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
public class Example {
public static void main(String[] args) throws Exception {
var config = new ClientConfiguration()
.apiUrl(System.getenv("FGA_API_URL"));
var fgaClient = new OpenFgaClient(config);
var body = new CreateStoreRequest()
.name("FGA Demo Store");
var response = fgaClient.createStore(body).get();
}
}# Set FGA_API_URL to the URL of your OpenFGA server.
# These examples use a server with authentication disabled.
# For authenticated servers, see /docs/getting-started/setup-sdk-client.
curl -X POST "$FGA_API_URL/stores" \
-H "content-type: application/json" \
-d '{
"name": "FGA Demo Store"
}'{
"created_at": "2023-11-07T05:31:56Z",
"id": "01YCP46JKYM8FJCQ37NMBYHE5X",
"name": "<string>",
"updated_at": "2023-11-07T05:31:56Z"
}{
"code": "validation_error",
"message": "Generic validation error"
}{
"code": "unauthenticated",
"message": "unauthenticated"
}{
"code": "forbidden",
"message": "the principal is not authorized to perform the action"
}{
"code": "undefined_endpoint",
"message": "Endpoint not enabled"
}{
"code": "10",
"message": "transaction conflict"
}{
"code": "throttled_timeout_error",
"message": "timeout due to throttling on complex request"
}{
"code": "internal_error",
"message": "Internal Server Error"
}Last modified on September 28, 2026
Was this page helpful?
⌘I
Node.js
const { OpenFgaClient, ConsistencyPreference } = require('@openfga/sdk');
const fgaClient = new OpenFgaClient({
apiUrl: process.env.FGA_API_URL,
});
async function main() {
const body = {
"name": "FGA Demo Store"
};
const response = await fgaClient.createStore(body);
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});package main
import (
"context"
"os"
. "github.com/openfga/go-sdk/client"
)
func main() {
fgaClient, err := NewSdkClient(&ClientConfiguration{
ApiUrl: os.Getenv("FGA_API_URL"),
})
if err != nil {
panic(err)
}
body := ClientCreateStoreRequest{
Name: "FGA Demo Store",
}
data, err := fgaClient.CreateStore(context.Background()).Body(body).Execute()
if err != nil {
panic(err)
}
_ = data
}using System.Collections.Generic;
using OpenFga.Sdk.Client;
using OpenFga.Sdk.Client.Model;
using OpenFga.Sdk.Model;
using Environment = System.Environment;
var fgaClient = new OpenFgaClient(new ClientConfiguration() {
ApiUrl = Environment.GetEnvironmentVariable("FGA_API_URL"),
});
var body = new ClientCreateStoreRequest {
Name = "FGA Demo Store",
};
var response = await fgaClient.CreateStore(body);import asyncio
import os
from openfga_sdk.client import OpenFgaClient, ClientConfiguration
from openfga_sdk.models import CreateStoreRequest
async def main():
configuration = ClientConfiguration(
api_url=os.environ.get("FGA_API_URL"),
)
async with OpenFgaClient(configuration) as fga_client:
body = CreateStoreRequest(
name="FGA Demo Store",
)
response = await fga_client.create_store(body)
asyncio.run(main())import dev.openfga.sdk.api.client.OpenFgaClient;
import dev.openfga.sdk.api.configuration.ClientConfiguration;
import dev.openfga.sdk.api.configuration.*;
import dev.openfga.sdk.api.client.model.*;
import dev.openfga.sdk.api.model.*;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
public class Example {
public static void main(String[] args) throws Exception {
var config = new ClientConfiguration()
.apiUrl(System.getenv("FGA_API_URL"));
var fgaClient = new OpenFgaClient(config);
var body = new CreateStoreRequest()
.name("FGA Demo Store");
var response = fgaClient.createStore(body).get();
}
}# Set FGA_API_URL to the URL of your OpenFGA server.
# These examples use a server with authentication disabled.
# For authenticated servers, see /docs/getting-started/setup-sdk-client.
curl -X POST "$FGA_API_URL/stores" \
-H "content-type: application/json" \
-d '{
"name": "FGA Demo Store"
}'{
"created_at": "2023-11-07T05:31:56Z",
"id": "01YCP46JKYM8FJCQ37NMBYHE5X",
"name": "<string>",
"updated_at": "2023-11-07T05:31:56Z"
}{
"code": "validation_error",
"message": "Generic validation error"
}{
"code": "unauthenticated",
"message": "unauthenticated"
}{
"code": "forbidden",
"message": "the principal is not authorized to perform the action"
}{
"code": "undefined_endpoint",
"message": "Endpoint not enabled"
}{
"code": "10",
"message": "transaction conflict"
}{
"code": "throttled_timeout_error",
"message": "timeout due to throttling on complex request"
}{
"code": "internal_error",
"message": "Internal Server Error"
}