Repository navigation
web sdk macros
A macro in Security Center is an entity that contains C# code. Macros run server-side and can automate tasks, react to events, or integrate with external systems. The Web SDK lets you query, create, publish, start, stop, and monitor macros through REST endpoints.
Macro requests require access to the macro's partition.
| Operation | Required access |
|---|---|
| List and read macro properties | View macro properties |
| Start, execute, and stop macros | Execute macros |
| Create macros, edit source code, set draft state, and publish macros | Administrator |
Start by listing macro entities and reading their stored source, draft state, and active execution data.
GET /report/EntityConfiguration?q=EntityTypes@Macro,Page=1,PageSize=100{
"Rsp": {
"Status": "Ok",
"Result": [
{
"Guid": "{macro-guid-1}"
},
{
"Guid": "{macro-guid-2}"
}
]
}
}GET /entity?q=entity={macro-guid},Name,SourceCode,IsDraft,RunningState,DefaultParameters{
"Rsp": {
"Status": "Ok",
"Result": {
"Name": "MyMacro",
"SourceCode": "using Genetec.Sdk.Scripting;\npublic sealed class myMacro : UserMacro\n{\n public override void Execute()\n {\n // macro logic here\n }\n protected override void CleanUp() { }\n}",
"IsDraft": false,
"RunningState": "Running",
"DefaultParameters": []
}
}
}-
Name- Macro name. -
SourceCode- The C# source code currently stored on the macro. -
IsDraft- Whentrue, the macro cannot be executed. -
RunningState- A coarse macro status field. Use/activemacrosdetailswhen you need the active execution instances and execution IDs. -
DefaultParameters- Array of default parameter values for the macro's execution context.
Newly created macros start with template source code that still contains throw new NotImplementedException();, so replace or edit it before you expect useful execution behavior.
Create the macro entity first, and then replace the default source with your own code.
POST /entity?q=entity=NewEntity(Macro),Name=MyMacro,Guid{
"Rsp": {
"Status": "Ok",
"Result": {
"Guid": "{new-macro-guid}"
}
}
}The macro is created with default template source code. Use SetSourceCode to replace it.
POST /entity?q=entity={macro-guid},SetSourceCode({url-encoded-source-code}){
"Rsp": {
"Status": "Ok"
}
}- Pass the URL-encoded source directly. Do not wrap it in
%22...%22. - The macro is compiled when the source code is set, unless the macro is in draft mode. Draft macros store the source without compiling; compilation occurs when the macro is published.
- If compilation fails, the call returns an error and the previously stored source remains in place.
- Only administrators can set macro source code.
You can combine creation and source code in a single request:
POST /entity?q=entity=NewEntity(Macro),Name=MyMacro,SetSourceCode({url-encoded-source-code}),GuidUse the same unquoted SetSourceCode({url-encoded-source-code}) form here.
A macro in draft state cannot be executed. Use SetMacroToDraft and PublishMacro to toggle the draft state.
POST /entity?q=entity={macro-guid},SetMacroToDraft(){
"Rsp": {
"Status": "Ok"
}
}This sets IsDraft to true. Only administrators can set macros to draft.
POST /entity?q=entity={macro-guid},PublishMacro(){
"Rsp": {
"Status": "Ok"
}
}This sets IsDraft to false and recompiles the source code. If compilation fails, the call returns an error and the macro stays in draft state.
Both methods start the macro using its default parameters. The Web SDK does not support passing custom parameter values at execution time. Configure default parameters in Config Tool before starting the macro.
POST /action?q=StartMacro({macro-guid}){
"Rsp": {
"Status": "Ok",
"Result": []
}
}This starts the macro but does not return the execution ID. To get the execution ID, use /activemacrosdetails after starting the macro, or use the Execute() method instead.
POST /entity?q=entity={macro-guid},Execute(){
"Rsp": {
"Status": "Ok",
"Result": {
"Execute": "{execution-id}"
}
}
}This starts the macro and returns the execution ID in the response. Use this execution ID to stop the specific instance.
- The same macro can have multiple instances running at the same time unless it is configured for single-instance execution.
- Each instance gets a unique execution ID.
There are two ways to stop a running macro instance. Both require the execution ID. Use StopMacro(...) from /action when you only have the execution ID. Use AbortInstance(...) from /entity when you are calling the method on a specific macro entity, where entity={macro-guid} identifies the macro and AbortInstance({execution-id}) identifies the running instance.
POST /action?q=StopMacro({execution-id}){
"Rsp": {
"Status": "Ok",
"Result": []
}
}POST /entity?q=entity={macro-guid},AbortInstance({execution-id}){
"Rsp": {
"Status": "Ok"
}
}- Get execution IDs from
/activemacrosdetailsor from theExecute()response. - Both methods stop the same execution instance.
Use the active-macro endpoints to see which macros are currently running and which execution IDs they were assigned. Use /activemacrosdetails to retrieve execution IDs for stopping or tracking specific macro instances.
GET /activemacros{
"Rsp": {
"Status": "Ok",
"Result": [
"{macro-guid-1}"
]
}
}The result is an empty array when no macros are running. If the same macro has multiple instances running, its GUID appears once per instance.
GET /activemacrosdetails{
"Rsp": {
"Status": "Ok",
"Result": [
{
"Entity": "{macro-guid}",
"ExecutionId": "{execution-id}",
"Instigator": "{user-guid}",
"StartTime": "2026-03-14T06:05:48.5880352Z"
}
]
}
}-
Entity- The GUID of the macro entity. -
ExecutionId- The unique identifier for this execution instance. -
Instigator- The GUID of the user who started the macro. -
StartTime- The UTC timestamp of when the macro started.
The result is an empty array when no macros are running.
Retrieve the list of assembly references configured for macro compilation in system configuration:
GET /entity?q=entity=00000000-0000-0000-0000-000000000007,GetMacroAssemblyReferences(){
"Rsp": {
"Status": "Ok",
"Result": {
"GetMacroAssemblyReferences": []
}
}
}- The entity
00000000-0000-0000-0000-000000000007is the system configuration entity. - Returns an array of assembly reference strings configured for macro compilation.
-
The /action endpoint: The
/actionendpoint and operational commands. -
The /entity endpoint: The
/entityendpoint and sharedq=query syntax. - Referencing entities: Entity discovery, search, and parameter formats.
- Overview
- Connecting to Security Center
- SDK certificates
- Referencing SDK assemblies
- ASP.NET hosting
- SDK compatibility
- Migrating to modern .NET
- Entities
- Entity cache
- Entity loading, cache, and query options
- Detecting entity changes
- Entity change event reference
- Transactions
- Security Center events
- Actions
- Security Desk
- Custom events
- Event-to-actions
- Managing macros
- ReportManager
- ReportManager query reference
- Access control raw events
- DownloadAllRelatedData and StrictResults
- Privileges
- Partitions
- Entity write restrictions
- About custom fields
- About video
- About cameras
- Enrolling a video unit
- Ingesting third-party video
- Archiver and auxiliary archiver roles
- Archive transfer
- About access control
- About cardholders and credentials
- About doors, areas, elevators, and access points
- About access rules and schedules
- About access control units and interface modules
- Enrolling an access control unit
- Door templates
- Visitors
- Mobile credentials
- About threat levels
- About alarms
- About incidents
- Maps
- Logging
- Overview
- Localization
- Certificates
- Lifecycle
- Threading
- State management
- Configuration
- Restricted configuration
- Events
- Queries
- Request manager
- Database
- Entity ownership
- Engine extensions
- Entity mappings
- Server management
- Custom privileges
- Custom entity types
- Resolving non-SDK assemblies
- Deploying plugins
- Modern .NET support
- Overview
- Localization
- Certificates
- Creating modules
- Tasks
- Pages
- Components
- Tile extensions
- Services
- Contextual actions
- Custom actions
- Options extensions
- Configuration pages
- Monitors
- Shared components
- Commands
- Extending events
- Map extensions
- Timeline providers
- Image extractors
- Credential encoders
- Credential readers
- Cardholder fields extractors
- Badge printers
- Content builders
- Dashboard widgets
- Incidents
- Logon providers
- Pinnable content builders
- Custom report pages
- Overview
- Getting started
- Media file formats
- MediaPlayer
- VideoSourceFilter
- MediaExporter
- MediaFile
- G64 converters
- FileCryptingManager
- PlaybackSequenceQuerier
- PlaybackStreamReader
- OverlayFactory
- PtzCoordinatesManager
- AudioTransmitter
- AudioRecorder
- AnalogMonitorController
- Camera blocking
- Overview
- Getting started
- Referencing entities
- Entity operations
- About access control in the Web SDK
- About video in the Web SDK
- Users and user groups
- Partitions
- Custom fields
- Custom card formats
- Actions
- Events and alarms
- Incidents
- Reports
- Tasks
- Macros
- Custom entity types
- System endpoints
- Performance guide
- Reference
- Endpoints
- Constants
- Enumerations
- Under the hood
- Troubleshooting