Resources/API Documentation/Organization Query API

API reference

Organization Query API

Retrieve your organization’s settings and its sweepstakes settings to build custom configuration views and displays across multiple sweepstakes.

POSThttps://backend.cleansweeps.app/graphql

Operation: QueryOrganization

Request

Send a JSON body with query and variables. Set Content-Type: application/json. Check both the HTTP response and GraphQL errors.

GraphQL
query QueryOrganization($organizationId: Int, $platform: String, $platformId: String) {
  organization(id: $organizationId, platform: $platform, platformId: $platformId) {
    id
    plan
    primaryEmail
    uiConfig
    referralBonusGive
    referralBonusReceive
    discountCodes
    sweepstakes {
      id
      isActive
      isOnline
      startDate
      endDate
      title
      entryManagement
      entryTotal
    }
    emailDomainProfile {
      id
      status
      domainName
      dnsRecords
      fromEmail
      displayName
      template
      subject
    }
  }
}

Variables

QueryOrganization variables
FieldTypeDetails
organizationIdIntOptional in the schema. Numeric organization ID.
platformStringOptional in the schema. Use Shopify for Shopify organizations.
platformIdStringOptional in the schema. Shop GID. Supply identifiers appropriate to your organization.

Authentication and Access Notes

This query is commonly used without an API key in current queryOrganization helper flows. For this reason, this documentation does not include x-api-key in the request examples. If your environment requires additional protection or custom server-side enforcement, authentication headers may be added separately by your implementation.

Available Response Fields

Expand available response fields

The following fields are available from organization queries and can be requested together. Organization Fields

  • id
  • plan
  • primaryEmail
  • uiConfig
  • referralBonusGive
  • referralBonusReceive
  • discountCodes
  • sweepstakes
  • emailDomainProfile

Sweepstakes Fields

  • id
  • isActive
  • isOnline
  • startDate
  • endDate
  • title
  • entryManagement
  • entryTotal

Email Domain Profile Fields

  • id
  • status
  • domainName
  • dnsRecords
  • fromEmail
  • displayName
  • template
  • subject

Request Behavior

The backend allows querying an organization using one or more of the following inputs:

  • organizationId
  • platform
  • platformId

These variables are optional at the GraphQL schema level. Your application helpers may supply different combinations depending on the use case.

Response (Shape & Meaning)

Expand response (shape & meaning)

Sample Response

Example
{
  "data": {
    "organization": {
      "id": 123,
      "plan": "Diamond",
      "primaryEmail": "info@example.com",
      "uiConfig": "{...}",
      "referralBonusGive": 10,
      "referralBonusReceive": 5,
      "discountCodes": "{\"WELCOME10\":{\"entryGive\":10,\"multiplierGive\":1}}",
      "sweepstakes": [
        {
          "id": 123,
          "isActive": true,
          "isOnline": true,
          "startDate": "2026-01-01T00:00:00.000Z",
          "endDate": "2026-04-26T23:59:59.000Z",
          "title": "Spring Sweepstakes",
          "entryManagement": "{...}",
          "entryTotal": 5000
        }
      ],
      "emailDomainProfile": {
        "id": 44,
        "status": "ACTIVE",
        "domainName": "mail.example.com",
        "dnsRecords": "{...}",
        "fromEmail": "support@example.com",
        "displayName": "Clean Sweeps",
        "template": "<html>...</html>",
        "subject": "Welcome"
      }
    }
  }
}

Field Notes

Expand field notes
Field Notes
FieldTypeDetails
idnumberThe numeric ID of the organization.
planstringThe organization’s current plan tier.
primaryEmailstringThe primary email address associated with the organization.
uiConfigJSON or stringOrganization-level UI configuration used across the app.
referralBonusGivenumberThe referral bonus value awarded by the organization.
referralBonusReceivenumberThe referral bonus value received by the referred customer.
discountCodesJSON or stringDiscount code configuration stored as JSON, often serialized as a string, then parsed in the UI.
sweepstakesarrayA list of sweepstakes associated with the organization.
emailDomainProfileobjectEmail sending domain configuration associated with the organization. Sweepstakes Field Notes
idnumberThe numeric ID of the sweepstake.
isActivebooleanWhether the sweepstake is currently active.
isOnlinebooleanWhether the sweepstake is visible or available online.
startDatedatetime stringThe sweepstake start date.
endDatedatetime stringThe sweepstake end date.
titlestringThe sweepstake title.
entryManagementJSON or stringSweepstake entry management configuration.
entryTotalnumberThe total number of entries currently associated with the sweepstake. Email Domain Profile Field Notes
idnumberThe numeric ID of the email domain profile.
statusstringThe current status of the email domain profile.
domainNamestringThe sending domain configured for email delivery.
dnsRecordsJSON or stringDNS record data required for domain verification and sending setup.
fromEmailstringThe default from email address for the domain profile.
displayNamestringThe default display name used for outgoing email.
templatestringThe stored email template content.
subjectstringThe default email subject configured in the profile.

Discount Codes Field

Expand discount codes field

discountCodes is stored and read as JSON, often serialized as a string, then parsed in the UI. Supported Shapes JSON object map:

Example
{
  "WELCOME10": { "entryGive": 10, "multiplierGive": 1 }
}

JSON array (legacy-compatible parser path):

Example
[
  {
    "code": "WELCOME10",
    "entryGive": 10,
    "multiplierGive": 1
  }
]

Recommended Canonical Shape

Example
{
  "WELCOME10": { "entryGive": 10, "multiplierGive": 1 },
  "VIP2X": { "entryGive": 0, "multiplierGive": 2 }
}

Current Helper Coverage

The following helpers currently exist in organization.ts: queryOrganization(...) Returns organization summary, sweepstakes, referral configuration, and UI config. queryOrganizationSweepstakesOnly(...) Returns a minimal sweepstakes list. queryOrganizationEmailDomainProfile(...) Returns organization data plus email domain profile. queryDiscountCodes(...) Returns discountCodes only.

Practical Example

Input

Example
{
  "organizationId": 123,
  "platform": "Shopify",
  "platformId": "gid://shopify/Shop/1234567890"
}

Result This request can return:

  • organization metadata such as plan and primary email
  • referral configuration values
  • discount code configuration
  • associated sweepstakes records
  • email domain profile configuration

The exact fields returned depend on the selection set included in the GraphQL query.

Best Practices

  • Only request the fields your integration needs
  • Use platform: "Shopify" when querying Shopify organizations in your current app flow
  • Parse discountCodes safely because it may be returned as serialized JSON
  • Prefer the canonical object-map structure for discountCodes when storing or consuming discount code configuration
  • Avoid documenting or exposing unnecessary authentication headers in integrations that do not require them