{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml","api-docs-content/apis/public_openapi.yaml":"api-docs-content/apis/public_openapi.yaml"},"props":{"metadata":{"markdoc":{"tagList":["openapi-code-sample","openapi-response-sample","replay-openapi","json-schema"]},"type":"markdown"},"seo":{"title":"Authentication and Brand Access"},"dynamicMarkdocComponents":["openapi"],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"authentication-and-brand-access","__idx":0},"children":["Authentication and Brand Access"]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"authentication","__idx":1},"children":["Authentication"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["RubyPlay Public API uses HTTP Basic Authentication. Every request must include an ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["Authorization"]}," header with Base64-encoded credentials:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"header":{"controls":{"copy":{}}},"source":"Authorization: Basic <base64(username:password)>\n"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Credentials are issued by RubyPlay during integration."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"user-types","__idx":2},"children":["User Types"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Every set of credentials has a user type. It determines how many brands you can act on, which endpoint path you use, and which endpoints are available to you. Your type is returned by the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/api/v1/self"]}," endpoint."]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Type"},"children":["Type"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Description"},"children":["Description"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["INDIVIDUAL"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["A single brand of an operator. This is the original integration setup and the type most current integrations use."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["PARTNER"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["An operator or aggregator acting on several brands with one set of credentials."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["THIRD_PARTY"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["An external supplier acting on the data of the brands it has been granted."]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"endpoint-paths","__idx":3},"children":["Endpoint Paths"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Most endpoints are available via two paths:"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Path"},"children":["Path"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Brand"},"children":["Brand"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/api/v1/{endpoint}"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Implicit (Without brandId). The brand is resolved from your credentials."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/api/v1/brands/{brandId}/{endpoint}"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Explicit (With brandId). The brand is specified in the path."]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Which path you use depends on your user type:"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Type"},"children":["Type"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Brands"},"children":["Brands"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Path"},"children":["Path"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["INDIVIDUAL"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Exactly one"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Both paths. The brand is resolved from your credentials when you omit ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["brandId"]},"."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["PARTNER"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["One or more"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Explicit only. A request without ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["brandId"]}," is rejected with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["400 BRAND_REQUIRED"]},"."]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["THIRD_PARTY"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["One or more"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Explicit only. A request without ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["brandId"]}," is rejected with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["400 BRAND_REQUIRED"]},"."]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["A request for a brand your account does not cover is rejected with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["403 BRAND_NOT_ALLOWED"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["On each endpoint page, the ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Without brandId"]}," and ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["With brandId"]}," tabs show the request for both paths."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"checking-your-account-details","__idx":4},"children":["Checking Your Account Details"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To find out your user type and which brands your account covers, call the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/api/v1/self"]}," endpoint. It returns your ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["principalType"]}," and the brands your credentials are allowed to operate on, together with the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["brandId"]}," values to use in the explicit-brand path."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This endpoint describes the account you authenticate with, so it takes no ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["brandId"]}," of its own and is available to every account."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["API Call Sample:"]}]},{"$$mdtype":"Tag","name":"OpenApiCodeSample","attributes":{"descriptionFile":"api-docs-content/apis/public_openapi.yaml","operationId":"getSelf","parameters":{},"environments":{},"codeSamplesResolved":[{"lang":"shell","title":"curl","source":"curl -i -X GET \\\n  -u '<username>:<password>' \\\n  https://asia.stage.rubyplay.io/api/v1/self"},{"lang":"javascript","title":"JavaScript","source":"const resp = await fetch(\n  `https://asia.stage.rubyplay.io/api/v1/self`,\n  {\n    method: 'GET',\n    headers: {\n      Authorization: 'Basic ' + btoa('<username>:<password>')\n    }\n  }\n);\n\nconst data = await resp.text();\nconsole.log(data);"},{"lang":"javascript","title":"Node.js","source":"import fetch from 'node-fetch';\n\nasync function run() {\n  const resp = await fetch(\n    `https://asia.stage.rubyplay.io/api/v1/self`,\n    {\n      method: 'GET',\n      headers: {\n        Authorization: 'Basic ' + Buffer.from('<username>:<password>').toString('base64')\n      }\n    }\n  );\n\n  const data = await resp.text();\n  console.log(data);\n}\n\nrun();"},{"lang":"python","title":"Python","source":"import requests\n\nurl = \"https://asia.stage.rubyplay.io/api/v1/self\"\n\nresponse = requests.get(url, auth=('<username>','<password>'))\n\ndata = response.json()\nprint(data)"},{"lang":"java","title":"Java","source":"import java.net.*;\nimport java.net.http.*;\nimport java.util.*;\n\npublic class App {\n  public static void main(String[] args) throws Exception {\n    var httpClient = HttpClient.newBuilder().build();\n\n    var host = \"https://asia.stage.rubyplay.io\";\n    var pathname = \"/api/v1/self\";\n    var request = HttpRequest.newBuilder()\n      .GET()\n      .uri(URI.create(host + pathname ))\n      .header(\"Authorization\", \"Basic \" + Base64.getEncoder().encodeToString((\"<username>:<password>\").getBytes()))\n      .build();\n\n    var response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());\n\n    System.out.println(response.body());\n  }\n}"},{"lang":"csharp","title":"C#","source":"using System;\nusing System.Net.Http;\nusing System.Threading.Tasks;\nusing System.Text;\nusing System.Net.Http.Headers;\n\npublic class Program\n{\n  public static async Task Main()\n  {\n    System.Net.Http.HttpClient client = new();\n\n    string base64String = Convert.ToBase64String(Encoding.ASCII.GetBytes(\"<username>:<password>\"));\n    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(@\"Basic\", base64String);\n\n    using HttpResponseMessage request = await client.GetAsync(\"https://asia.stage.rubyplay.io/api/v1/self\");\n    string response = await request.Content.ReadAsStringAsync();\n\n    Console.WriteLine(response);\n  }\n}"},{"lang":"php","title":"PHP","source":"/**\n * Requires libcurl\n */\n\n$curl = curl_init();\n\ncurl_setopt_array($curl, [\n  CURLOPT_HTTPHEADER => [\n    \"Authorization: Basic \" . base64_encode(\"<username>:<password>\")\n  ],\n  CURLOPT_URL => \"https://asia.stage.rubyplay.io/api/v1/self\",\n  CURLOPT_RETURNTRANSFER => true,\n  CURLOPT_CUSTOMREQUEST => \"GET\",\n]);\n\n$response = curl_exec($curl);\n$error = curl_error($curl);\n\ncurl_close($curl);\n\nif ($error) {\n  echo \"cURL Error #:\" . $error;\n} else {\n  echo $response;\n}"},{"lang":"go","title":"Go","source":"package main\n\nimport (\n  \"fmt\"\n  \"net/http\"\n  \"io/ioutil\"\n)\n\nfunc main() {\n  reqUrl := \"https://asia.stage.rubyplay.io/api/v1/self\"\n  req, err := http.NewRequest(\"GET\", reqUrl, nil)\n  if err != nil {\n    panic(err)\n  }\n  req.SetBasicAuth(\"<username>\", \"<password>\")\n  res, err := http.DefaultClient.Do(req)\n  if err != nil {\n    panic(err)\n  }\n  defer res.Body.Close()\n  body, err := ioutil.ReadAll(res.Body)\n  if err != nil {\n    panic(err)\n  }\n\n  fmt.Println(res)\n  fmt.Println(string(body))\n}"},{"lang":"ruby","title":"Ruby","source":"require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI('https://asia.stage.rubyplay.io/api/v1/self')\n\nhttp = Net::HTTP.new(url.host, url.port)\nhttp.use_ssl = true\n\nrequest = Net::HTTP::Get.new(url)\nrequest.basic_auth('<username>', '<password>')\n\nresponse = http.request(request)\nputs response.read_body\n"},{"lang":"r","title":"R","source":"library(httr)\n\nurl = \"https://asia.stage.rubyplay.io/api/v1/self\"\n\ndata_req <- GET(\n  url,\n  authenticate(\"<username>\", \"<password>\")\n  verbose()\n)\n\ncontent(data_req)"}]},"children":[]},{"$$mdtype":"Tag","name":"OpenApiResponseSample","attributes":{"descriptionFile":"api-docs-content/apis/public_openapi.yaml","operationId":"getSelf","responseSamplesResolved":[{"lang":"json","title":"200 application/json","source":"{\n  \"allowedBrands\": [\n    {\n      \"id\": 1,\n      \"name\": \"Brand\"\n    }\n  ],\n  \"principalType\": \"INDIVIDUAL\"\n}"},{"lang":"json","title":"401 application/json","source":"{\n  \"code\": \"NOT_AUTHORIZED\",\n  \"message\": \"Authentication failed\",\n  \"timestamp\": \"2026-01-25T14:30:00Z\",\n  \"path\": \"/api/v1/self\"\n}"},{"lang":"json","title":"403 application/json","source":"{\n  \"code\": \"INVALID_REQUEST\",\n  \"message\": \"The requested campaign ID is invalid or does not exist\",\n  \"timestamp\": \"2025-01-15T10:30:00Z\",\n  \"path\": \"/api/v1/campaigns/123\"\n}"},{"lang":"json","title":"500 application/json","source":"{\n  \"code\": \"UNKNOWN_ERROR\",\n  \"message\": \"Something went wrong\",\n  \"timestamp\": \"2026-01-25T14:30:00Z\",\n  \"path\": \"/api/v1/self\"\n}"},{"lang":"json","title":"504 application/json","source":"{\n  \"code\": \"TIMEOUT\",\n  \"message\": \"The server did not respond within the expected time\",\n  \"timestamp\": \"2026-01-25T14:30:00Z\",\n  \"path\": \"/api/v1/self\"\n}"}]},"children":[]},{"$$mdtype":"Tag","name":"ReplayOpenApi","attributes":{"descriptionFile":"api-docs-content/apis/public_openapi.yaml","operationId":"getSelf","parameters":{},"options":{},"environments":{},"environment":"stage"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Response Schema:"]}]},{"$$mdtype":"Tag","name":"JsonSchema","attributes":{"schema":{"$ref":"../../apis/public_openapi.yaml#/components/schemas/SelfDto"},"options":{},"schemaResolved":{"openapi":"3.1.0","components":{"schemas":{"__root":{"$ref":"#/components/schemas/SelfDto"},"BrandDto":{"type":"object","properties":{"id":{"type":"integer","format":"int32","description":"Brand ID","example":1},"name":{"type":"string","description":"Brand name","example":"Brand"}}},"SelfDto":{"type":"object","properties":{"allowedBrands":{"type":"array","items":{"$ref":"#/components/schemas/BrandDto","description":"List of brands the authenticated user is allowed to operate on."}},"principalType":{"type":"string","description":"Type of principal the account belongs to.","enum":["INTERNAL","THIRD_PARTY","INDIVIDUAL"],"example":"INDIVIDUAL"}}}}}},"schemaResolvedErrors":[]},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Use ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["principalType"]}," to determine which endpoint path applies to your account, and the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["id"]}," of the brand you are acting on as the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["brandId"]}," in the explicit-brand path."]}]},"headings":[{"value":"Authentication and Brand Access","id":"authentication-and-brand-access","depth":2},{"value":"Authentication","id":"authentication","depth":3},{"value":"User Types","id":"user-types","depth":3},{"value":"Endpoint Paths","id":"endpoint-paths","depth":3},{"value":"Checking Your Account Details","id":"checking-your-account-details","depth":3}],"frontmatter":{"seo":{"title":"Authentication and Brand Access"}},"lastModified":"2026-09-24T09:57:59.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/content/integration/public-api/authentication-and-authorization","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}