# Business

> Read business state, submit authorized employee announcements or publish from trusted server integrations.

**Server only · sky_jobs_base.** The global feature and the registered job's relevant `businessSettings` capabilities must be enabled.

## Authorized employee APIs

Use the authenticated server-handler source, not a player ID supplied by a client payload.

<table>
<thead>
  <tr>
    <th>
      Export
    </th>
    
    <th>
      Returns
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        GetBusinessContext(source)
      </code>
    </td>
    
    <td>
      <code>
        { success = true, data = context }
      </code>
      
       or <code>
        { success = false, error }
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        GetBusinessHistory(source, { job, before? })
      </code>
    </td>
    
    <td>
      <code>
        { success = true, data = { entries, nextCursor? } }
      </code>
      
       or <code>
        { success = false, error }
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        SubmitBusinessAnnouncement(source, { job, kind, message? })
      </code>
    </td>
    
    <td>
      <code>
        { success = true, data = context }
      </code>
      
       or <code>
        { success = false, error, retryAfter? }
      </code>
    </td>
  </tr>
</tbody>
</table>

`context` contains `job`, `label`, `color`, `imageUrl`, optional `open`, `canChangeStatus`, `canAnnounce`, `cooldown` and `maxLength = 240`. Submission checks the current job, configured feature, duty, permissions, validation and employee cooldown.

`kind` is `open`, `closed`, `announcement`, `promotion` or `event`. Opening/closing text can be omitted; the other kinds require text. Text is limited to 240 Unicode characters and 960 bytes. The server derives the image and recipients.

```lua [inside an existing authorized server callback]
local context = exports["sky_jobs_base"]:GetBusinessContext(sourceId)
if not context.success then
    return context
end

return exports["sky_jobs_base"]:SubmitBusinessAnnouncement(sourceId, {
    job = context.data.job,
    kind = "promotion",
    message = "Two loaves for the price of one."
})
```

The callback's `sourceId` must be the authenticated caller. Do not accept another player's ID as an input to this example.

History entries contain `id`, `timestamp` (epoch milliseconds), `name`, `action` and `content`. Each page has up to 25 entries. Pass `nextCursor` unchanged as `before` for the next page, together with the same current `job`.

Access errors include `disabled`, `not_authorized`, `off_duty` and `context_changed`. Submission can also return `invalid_payload`, `invalid_kind`, `invalid_message`, `cooldown`, `busy`, `unchanged` or `failed`. Cooldown responses include `retryAfter` in seconds.

## Trusted server integrations

These exports are for server-controlled automation. They do not authorize an employee through `actorId` and do not apply the employee publishing cooldown. For a player action, use `SubmitBusinessAnnouncement` above.

<table>
<thead>
  <tr>
    <th>
      Export
    </th>
    
    <th>
      Returns / behavior
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        GetBusinessState(job)
      </code>
    </td>
    
    <td>
      <code>
        { open, openColor, closedColor, openSprite, closedSprite, closedAlpha }
      </code>
      
      , or <code>
        nil
      </code>
      
       when unavailable
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        SetBusinessOpen(job, open, message?, announce?, actorId?)
      </code>
    </td>
    
    <td>
      <code>
        true
      </code>
      
       or <code>
        false, reason
      </code>
      
      ; changes persisted opening state, blips and history
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        BroadcastBusinessAnnouncement(job, kind, message?, actorId?)
      </code>
    </td>
    
    <td>
      <code>
        true
      </code>
      
       or <code>
        false, reason
      </code>
      
      ; notice/history only, without an opening-state change
    </td>
  </tr>
</tbody>
</table>

`announce` defaults to `true`; `false` makes a status change silent. An unchanged status returns `false, "unchanged"`. Optional `actorId` supplies trusted history/admin context, not a permission check. Broadcast additionally supports `zone_created` and `zone_removed` for server-controlled zone notifications.

```lua [server automation in a yielding thread or callback]
local changed, reason = exports["sky_jobs_base"]:SetBusinessOpen(
    "bakery", true, "Fresh bread is ready!"
)

local sent, sendReason = exports["sky_jobs_base"]:BroadcastBusinessAnnouncement(
    "police", "announcement", "Road closed at Legion Square."
)
```

Replace the example jobs with enabled jobs registered on your server. Global/job enablement, input validation, storage and busy-state checks still apply. See the [feature/setup guide](/docs/base/jobs-base/features/business-and-announcements).
