Repository navigation
Expand file tree
/
Copy pathopenapi.yaml
More file actions
2056 lines (2055 loc) · 93.3 KB
/
Copy pathopenapi.yaml
File metadata and controls
2056 lines (2055 loc) · 93.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
openapi: 3.0.3
info:
title: MotifEngine API
version: 0.2.0
description: Tenant-scoped event, rule, points, progression, and reward APIs.
servers:
- url: http://127.0.0.1:18080
tags:
- name: Events
- name: Users
- name: Rewards
- name: Leaderboards
- name: Administration
paths:
/v1/admin/auth/signup:
post:
tags: [Administration]
summary: Create a tenant workspace and owner session
description: Self-serve tenant signup. Super Admin accounts are provisioned privately for the Ops service.
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [email, password, tenant_id, name]
properties:
email: { type: string, format: email }
password: { type: string, format: password, minLength: 12 }
tenant_id: { type: string, pattern: '^[a-z0-9][a-z0-9_-]{0,63}$' }
name: { type: string }
environment_id: { type: string, default: production }
environment_name: { type: string, default: Production }
responses:
'201': { description: Workspace and owner session. No access key is created; workspace admins create keys with POST /v1/admin/access-keys. }
'409': { $ref: '#/components/responses/Conflict' }
'400': { $ref: '#/components/responses/ValidationError' }
/v1/admin/auth/login:
post:
tags: [Administration]
summary: Create an administrator session
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [email, password]
properties:
email: { type: string, format: email }
password: { type: string, format: password }
responses:
'200': { description: Session token and administrator identity }
'401': { $ref: '#/components/responses/Unauthorized' }
/v1/admin/auth/logout:
post:
tags: [Administration]
security: [{ adminSession: [] }]
summary: Revoke the current administrator session
responses: { '204': { description: Session revoked } }
/v1/admin/auth/me:
get:
tags: [Administration]
security: [{ adminSession: [] }, { adminKey: [] }]
summary: Read the current administrator principal
responses: { '200': { description: Administrator principal } }
/metrics:
get:
tags: [Administration]
summary: Read Prometheus metrics
responses: { '200': { description: Prometheus text exposition } }
/v1/events:
post:
tags: [Events]
security: [{ accessKey: [] }]
summary: Accept an event
requestBody:
required: true
content:
application/json:
schema: { $ref: '#/components/schemas/EventRequest' }
responses:
'202':
description: Event accepted for asynchronous processing
content:
application/json:
schema: { $ref: '#/components/schemas/EventReceipt' }
'409': { $ref: '#/components/responses/Conflict' }
'422': { $ref: '#/components/responses/ValidationError' }
/v1/events/{externalEventId}:
get:
tags: [Events]
security: [{ accessKey: [] }]
summary: Read event processing status
parameters:
- $ref: '#/components/parameters/ExternalEventId'
responses:
'200':
description: Event receipt
content:
application/json:
schema: { $ref: '#/components/schemas/EventReceipt' }
'404': { $ref: '#/components/responses/NotFound' }
/v1/users/{externalUserId}/profile:
get:
tags: [Users]
security: [{ accessKey: [] }]
summary: Read user profile, balances, and mission progress
parameters: [{ $ref: '#/components/parameters/ExternalUserId' }]
responses:
'200':
description: User profile
content: { application/json: { schema: { $ref: '#/components/schemas/Profile' } } }
/v1/users/{externalUserId}/points:
get:
tags: [Users]
security: [{ accessKey: [] }]
summary: Read point balances
parameters: [{ $ref: '#/components/parameters/ExternalUserId' }]
responses:
'200':
description: Point balances
content: { application/json: { schema: { $ref: '#/components/schemas/Balances' } } }
/v1/users/{externalUserId}/points/transactions:
get:
tags: [Users]
security: [{ accessKey: [] }]
summary: Read point ledger transactions
parameters:
- $ref: '#/components/parameters/ExternalUserId'
- $ref: '#/components/parameters/Limit'
- $ref: '#/components/parameters/Cursor'
responses:
'200':
description: Ledger entries ordered newest first
content: { application/json: { schema: { $ref: '#/components/schemas/Transactions' } } }
post:
tags: [Users]
security: [{ accessKey: [] }]
summary: Award or spend points directly
description: The idempotency key makes a retried request return the original entry; reusing it with different content returns 409.
parameters:
- $ref: '#/components/parameters/ExternalUserId'
requestBody:
required: true
content: { application/json: { schema: { $ref: '#/components/schemas/UserTransactionRequest' } } }
responses:
'201': { description: Ledger entry recorded }
'404': { $ref: '#/components/responses/NotFound' }
'409': { $ref: '#/components/responses/Conflict' }
/v1/users/{externalUserId}/achievements:
get:
tags: [Users]
security: [{ accessKey: [] }]
summary: Read achievement progress and unlocks
parameters: [{ $ref: '#/components/parameters/ExternalUserId' }]
responses:
'200':
description: Achievement progress
content: { application/json: { schema: { $ref: '#/components/schemas/Achievements' } } }
/v1/users/{externalUserId}/missions:
get:
tags: [Users]
security: [{ accessKey: [] }]
summary: Read mission progress
parameters: [{ $ref: '#/components/parameters/ExternalUserId' }]
responses:
'200': { description: Mission progress }
/v1/admin/user-profile:
get:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }]
summary: Read a scoped user snapshot for operations
parameters:
- { name: tenant_id, in: query, required: true, schema: { type: string } }
- { name: environment_id, in: query, required: true, schema: { type: string } }
- { name: user_id, in: query, required: true, schema: { type: string } }
responses: { '200': { description: User snapshot } }
/v1/admin/user-transactions:
get:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }]
summary: Read a scoped user ledger
parameters:
- { name: tenant_id, in: query, required: true, schema: { type: string } }
- { name: environment_id, in: query, required: true, schema: { type: string } }
- { name: user_id, in: query, required: true, schema: { type: string } }
- { $ref: '#/components/parameters/Limit' }
- { $ref: '#/components/parameters/Cursor' }
responses: { '200': { description: User ledger entries } }
/v1/users/{externalUserId}/progression:
get:
tags: [Users]
security: [{ accessKey: [] }]
summary: Read XP and current level
parameters: [{ $ref: '#/components/parameters/ExternalUserId' }]
responses:
'200':
description: User progression
content: { application/json: { schema: { $ref: '#/components/schemas/UserProgression' } } }
/v1/users/{externalUserId}/streaks:
get:
tags: [Users]
security: [{ accessKey: [] }]
summary: Read a user's current and longest event streak
parameters:
- { $ref: '#/components/parameters/ExternalUserId' }
- { name: event_type, in: query, schema: { type: string } }
responses: { '200': { description: Streak state } }
/v1/users/{externalUserId}/leaderboards:
get:
tags: [Leaderboards]
security: [{ accessKey: [] }]
summary: Read a user's place on every active leaderboard
description: Entry is null on a board where the user has not scored in the round shown.
parameters: [{ $ref: '#/components/parameters/ExternalUserId' }]
responses:
'200':
description: The user's standings
content:
application/json:
schema:
type: object
properties:
user_id: { type: string }
leaderboards: { type: array, items: { $ref: '#/components/schemas/UserLeaderboardStanding' } }
/v1/leaderboards:
get:
tags: [Leaderboards]
security: [{ accessKey: [] }]
summary: List active leaderboards with the round each one shows
responses:
'200':
description: Active leaderboards
content:
application/json:
schema:
type: object
properties: { leaderboards: { type: array, items: { $ref: '#/components/schemas/Leaderboard' } } }
/v1/leaderboards/{leaderboardKey}:
get:
tags: [Leaderboards]
security: [{ accessKey: [] }]
summary: Read a leaderboard's ranking
description: >-
With round=current (the default) this returns the running round. When no round is running it
returns the last round that started, with status ended, so a page between two manual rounds
shows final results. Ranks are unique: a higher score ranks first, then whoever reached the
score first.
parameters:
- $ref: '#/components/parameters/LeaderboardKey'
- { name: round, in: query, schema: { type: string, default: current }, description: 'current, previous (the last round that ended), or a round number' }
- { name: limit, in: query, schema: { type: integer, minimum: 1, maximum: 100, default: 10 } }
- { name: offset, in: query, schema: { type: integer, minimum: 0, maximum: 10000, default: 0 } }
responses:
'200': { description: Standings, content: { application/json: { schema: { $ref: '#/components/schemas/LeaderboardStandings' } } } }
'404': { $ref: '#/components/responses/NotFound' }
/v1/leaderboards/{leaderboardKey}/rounds:
get:
tags: [Leaderboards]
security: [{ accessKey: [] }]
summary: List a leaderboard's rounds, newest first, with each round's leader
parameters:
- $ref: '#/components/parameters/LeaderboardKey'
- { name: limit, in: query, schema: { type: integer, minimum: 1, maximum: 100, default: 10 } }
responses:
'200':
description: Rounds
content:
application/json:
schema:
type: object
properties:
leaderboard: { $ref: '#/components/schemas/Leaderboard' }
rounds: { type: array, items: { $ref: '#/components/schemas/LeaderboardRound' } }
'404': { $ref: '#/components/responses/NotFound' }
/v1/points/conversions:
post:
tags: [Users]
security: [{ accessKey: [] }]
summary: Convert points atomically between currencies
requestBody:
required: true
content: { application/json: { schema: { $ref: '#/components/schemas/ConversionRequest' } } }
responses:
'201':
description: Conversion record
content: { application/json: { schema: { $ref: '#/components/schemas/Conversion' } } }
'409': { $ref: '#/components/responses/Conflict' }
/v1/rewards/{rewardId}/redemptions:
post:
tags: [Rewards]
security: [{ accessKey: [] }]
summary: Redeem a reward through the configured provider
parameters: [{ $ref: '#/components/parameters/RewardId' }]
requestBody:
required: true
content: { application/json: { schema: { $ref: '#/components/schemas/RedemptionRequest' } } }
responses:
'201':
description: Redemption state (idempotent for the same user and key)
content: { application/json: { schema: { $ref: '#/components/schemas/Redemption' } } }
'409': { $ref: '#/components/responses/Conflict' }
/v1/redemptions/{redemptionId}:
get:
tags: [Rewards]
security: [{ accessKey: [] }]
summary: Read redemption status
parameters: [{ $ref: '#/components/parameters/RedemptionId' }]
responses:
'200':
description: Redemption
content: { application/json: { schema: { $ref: '#/components/schemas/Redemption' } } }
'404': { $ref: '#/components/responses/NotFound' }
/v1/redemptions/{redemptionId}/retry:
post:
tags: [Rewards]
security: [{ accessKey: [] }]
summary: Retry a failed or interrupted redemption
parameters: [{ $ref: '#/components/parameters/RedemptionId' }]
responses:
'200':
description: Redemption delivery state after retry
content: { application/json: { schema: { $ref: '#/components/schemas/Redemption' } } }
'409': { $ref: '#/components/responses/Conflict' }
/v1/admin/tenants:
get:
tags: [Administration]
security: [{ adminKey: [] }]
summary: List tenant environments
responses: { '200': { description: Tenant environments } }
post:
tags: [Administration]
security: [{ adminKey: [] }]
summary: Create a tenant and environment
responses: { '201': { description: Tenant created } }
/v1/admin/tenants/{tenantId}/status:
post:
tags: [Administration]
security: [{ adminKey: [] }]
summary: Suspend or activate a tenant
parameters:
- { name: tenantId, in: path, required: true, schema: { type: string } }
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [status]
properties:
status: { type: string, enum: [active, suspended] }
responses:
'200': { description: Tenant status changed }
'404': { $ref: '#/components/responses/NotFound' }
/v1/admin/environments:
get:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }]
summary: List environments for a tenant
parameters:
- { name: tenant_id, in: query, required: true, schema: { type: string } }
responses: { '200': { description: Tenant environments } }
post:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }]
summary: Add an environment to an existing tenant
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [tenant_id, environment_id, name]
properties:
tenant_id: { type: string }
environment_id: { type: string }
name: { type: string }
responses: { '201': { description: Environment created } }
/v1/admin/audit-log:
get:
tags: [Administration]
security: [{ adminKey: [] }]
summary: List tenant and platform mutations
parameters:
- { name: tenant_id, in: query, schema: { type: string } }
- { name: environment_id, in: query, schema: { type: string } }
- { name: action, in: query, schema: { type: string } }
- { $ref: '#/components/parameters/Limit' }
responses:
'200':
description: Audit entries ordered newest first
content: { application/json: { schema: { type: array, items: { $ref: '#/components/schemas/AuditEntry' } } } }
/v1/admin/plans:
get:
tags: [Administration]
security: [{ adminKey: [] }]
summary: List active and inactive platform plans
responses:
'200':
description: Plan definitions
content: { application/json: { schema: { type: array, items: { $ref: '#/components/schemas/Plan' } } } }
post:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }]
summary: Create a manual or subscription plan
requestBody:
required: true
content: { application/json: { schema: { $ref: '#/components/schemas/PlanRequest' } } }
responses: { '201': { description: Plan created } }
/v1/admin/plans/{planId}:
patch:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }]
summary: Update a plan
parameters: [{ name: planId, in: path, required: true, schema: { type: string } }]
requestBody:
required: true
content: { application/json: { schema: { $ref: '#/components/schemas/PlanRequest' } } }
responses: { '200': { description: Plan updated } }
/v1/admin/plans/{planId}/archive:
post:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }]
summary: Archive a plan
parameters: [{ name: planId, in: path, required: true, schema: { type: string } }]
responses: { '200': { description: Plan archived } }
/v1/admin/tenant-plans:
get:
tags: [Administration]
security: [{ adminKey: [] }]
summary: Read effective tenant entitlements
parameters: [{ name: tenant_id, in: query, schema: { type: string } }]
responses:
'200':
description: Tenant plan assignments
content: { application/json: { schema: { type: array, items: { $ref: '#/components/schemas/TenantPlan' } } } }
post:
tags: [Administration]
security: [{ adminKey: [] }]
summary: Assign a plan and optional tenant overrides
requestBody:
required: true
content: { application/json: { schema: { $ref: '#/components/schemas/TenantPlanRequest' } } }
responses: { '200': { description: Tenant plan assigned } }
/v1/admin/usage:
get:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }]
summary: Read tenant resource usage and effective limits
parameters: [{ name: tenant_id, in: query, required: true, schema: { type: string } }]
responses:
'200':
description: Usage snapshot
content: { application/json: { schema: { $ref: '#/components/schemas/Usage' } } }
/v1/admin/admin-users:
get:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }]
summary: List administrator identities
responses: { '200': { description: Administrator identities without password hashes } }
post:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }]
summary: Create an administrator identity
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [email, password, role]
properties:
email: { type: string, format: email }
password: { type: string, minLength: 12, format: password }
role: { type: string, enum: [super_admin, tenant_admin] }
tenant_ids: { type: array, items: { type: string } }
responses: { '201': { description: Administrator created } }
/v1/admin/diagnostics:
get:
tags: [Administration]
security: [{ adminKey: [] }]
summary: Read live event, execution, and redemption counters
parameters:
- { name: tenant_id, in: query, schema: { type: string } }
- { name: environment_id, in: query, schema: { type: string } }
responses:
'200':
description: Operational diagnostics snapshot
content: { application/json: { schema: { $ref: '#/components/schemas/Diagnostics' } } }
/v1/admin/event-types:
get:
tags: [Administration]
security: [{ adminKey: [] }]
summary: List event contracts
parameters:
- { name: tenant_id, in: query, schema: { type: string } }
- { name: environment_id, in: query, schema: { type: string } }
responses: { '200': { description: Event contracts } }
post:
tags: [Administration]
security: [{ adminKey: [] }]
summary: Register an event contract
responses: { '201': { description: Event contract created } }
/v1/admin/event-types/{eventType}/versions:
get:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }]
summary: List immutable event contract versions
parameters:
- { name: eventType, in: path, required: true, schema: { type: string } }
- { name: tenant_id, in: query, required: true, schema: { type: string } }
- { name: environment_id, in: query, required: true, schema: { type: string } }
responses: { '200': { description: Event contract version history } }
/v1/admin/events:
get:
tags: [Administration]
security: [{ adminKey: [] }]
summary: List received events
parameters:
- { $ref: '#/components/parameters/Limit' }
- { $ref: '#/components/parameters/Offset' }
- { name: tenant_id, in: query, schema: { type: string } }
- { name: environment_id, in: query, schema: { type: string } }
- { name: status, in: query, schema: { type: string, enum: [accepted, processing, processed, failed] } }
responses: { '200': { description: Received events } }
/v1/admin/events/test:
post:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }]
summary: Ingest a scoped test event from the console
requestBody:
required: true
content: { application/json: { schema: { $ref: '#/components/schemas/ScopedEventRequest' } } }
responses: { '202': { description: Event accepted }, '409': { $ref: '#/components/responses/Conflict' } }
/v1/admin/events/{externalEventId}/trace:
get:
tags: [Administration]
security: [{ adminSession: [] }, { accessKeyBearer: [] }, { adminKey: [] }]
summary: Explain what one event did
description: Returns the receipt, the rule executions and the point and XP entries the event produced, the missions and achievements it advanced, and a fresh evaluation of every currently published rule for its event type, including the expression that decided a non-match.
parameters:
- $ref: '#/components/parameters/ExternalEventId'
- { name: tenant_id, in: query, required: true, schema: { type: string } }
- { name: environment_id, in: query, required: true, schema: { type: string } }
responses:
'200': { description: Event trace, content: { application/json: { schema: { $ref: '#/components/schemas/EventTrace' } } } }
'404': { $ref: '#/components/responses/NotFound' }
/v1/admin/rules:
get:
tags: [Administration]
security: [{ adminKey: [] }]
summary: List rules
parameters:
- { name: tenant_id, in: query, schema: { type: string } }
- { name: environment_id, in: query, schema: { type: string } }
responses:
'200':
description: Rules with their active schedule windows
content: { application/json: { schema: { type: array, items: { $ref: '#/components/schemas/Rule' } } } }
post:
tags: [Administration]
security: [{ adminKey: [] }]
summary: Create a rule draft
requestBody:
required: true
content: { application/json: { schema: { $ref: '#/components/schemas/RuleRequest' } } }
responses:
'201':
description: Rule created
content: { application/json: { schema: { $ref: '#/components/schemas/Rule' } } }
/v1/admin/rules/check:
post:
tags: [Administration]
security: [{ adminSession: [] }, { accessKeyBearer: [] }, { adminKey: [] }]
summary: Check a rule without saving it
description: Validates the rule, checks its event contract and currencies in the environment, and evaluates an optional sample payload. Validation problems are returned with valid set to false rather than as an error status.
requestBody:
required: true
content: { application/json: { schema: { $ref: '#/components/schemas/RuleCheckRequest' } } }
responses:
'200': { description: Check result, content: { application/json: { schema: { $ref: '#/components/schemas/RuleCheck' } } } }
'404': { $ref: '#/components/responses/NotFound' }
/v1/admin/rules/{ruleId}/publish:
post:
tags: [Administration]
security: [{ adminKey: [] }]
summary: Publish the current rule version
parameters: [{ $ref: '#/components/parameters/RuleId' }]
responses:
'200':
description: Rule published
content: { application/json: { schema: { $ref: '#/components/schemas/Rule' } } }
/v1/admin/rules/{ruleId}/versions:
get:
tags: [Administration]
security: [{ adminKey: [] }]
summary: List immutable rule versions
parameters: [{ $ref: '#/components/parameters/RuleId' }]
responses:
'200':
description: Rule version history
content: { application/json: { schema: { type: array, items: { $ref: '#/components/schemas/RuleVersion' } } } }
post:
tags: [Administration]
security: [{ adminKey: [] }]
summary: Create a new draft rule version
parameters: [{ $ref: '#/components/parameters/RuleId' }]
requestBody:
required: true
content: { application/json: { schema: { $ref: '#/components/schemas/RuleVersionRequest' } } }
responses: { '201': { description: Draft version created } }
/v1/admin/rules/{ruleId}/versions/{version}/publish:
post:
tags: [Administration]
security: [{ adminKey: [] }]
summary: Publish a specific immutable rule version
parameters:
- { $ref: '#/components/parameters/RuleId' }
- { name: version, in: path, required: true, schema: { type: integer, minimum: 1 } }
responses: { '200': { description: Rule version published } }
/v1/admin/currencies:
get:
tags: [Administration]
security: [{ adminKey: [] }]
summary: List point currencies
responses: { '200': { description: Currencies } }
post:
tags: [Administration]
security: [{ adminKey: [] }]
summary: Create a point currency
responses: { '201': { description: Currency created } }
/v1/admin/missions:
get:
tags: [Administration]
security: [{ adminKey: [] }]
summary: List missions
responses: { '200': { description: Missions } }
post:
tags: [Administration]
security: [{ adminKey: [] }]
summary: Create a mission
responses: { '201': { description: Mission created } }
/v1/admin/goals:
get:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }]
summary: List business goals
parameters:
- { name: tenant_id, in: query, schema: { type: string } }
- { name: environment_id, in: query, schema: { type: string } }
responses: { '200': { description: Goals } }
post:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }]
summary: Create a measurable business goal
requestBody:
required: true
content: { application/json: { schema: { $ref: '#/components/schemas/GoalRequest' } } }
responses: { '201': { description: Goal created } }
/v1/admin/campaigns:
get:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }]
summary: List scheduled campaigns
parameters:
- { name: tenant_id, in: query, schema: { type: string } }
- { name: environment_id, in: query, schema: { type: string } }
responses: { '200': { description: Campaigns } }
post:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }]
summary: Create a scheduled campaign
requestBody:
required: true
content: { application/json: { schema: { $ref: '#/components/schemas/CampaignRequest' } } }
responses: { '201': { description: Campaign created } }
/v1/admin/analytics:
get:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }]
summary: Read campaign event and unique-user measurements
parameters:
- { name: tenant_id, in: query, required: true, schema: { type: string } }
- { name: environment_id, in: query, required: true, schema: { type: string } }
responses: { '200': { description: Campaign analytics } }
/v1/admin/metrics:
get:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }]
summary: List business metric definitions for a scope
parameters:
- { name: tenant_id, in: query, required: true, schema: { type: string } }
- { name: environment_id, in: query, required: true, schema: { type: string } }
responses:
'200':
description: Metric definitions
content: { application/json: { schema: { type: array, items: { $ref: '#/components/schemas/MetricDefinition' } } } }
post:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }]
summary: Create a business metric definition
requestBody:
required: true
content: { application/json: { schema: { $ref: '#/components/schemas/MetricRequest' } } }
responses:
'201':
description: Metric definition created
content: { application/json: { schema: { $ref: '#/components/schemas/MetricDefinition' } } }
/v1/admin/metrics/{metricId}/archive:
post:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }]
summary: Archive a metric definition without deleting history
parameters:
- { $ref: '#/components/parameters/MetricId' }
- { name: tenant_id, in: query, required: true, schema: { type: string } }
- { name: environment_id, in: query, required: true, schema: { type: string } }
responses: { '200': { description: Metric definition archived } }
/v1/admin/analytics/funnel:
post:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }]
summary: Measure ordered user conversion through event steps
requestBody:
required: true
content: { application/json: { schema: { $ref: '#/components/schemas/FunnelRequest' } } }
responses:
'200':
description: Funnel report with explicit step denominators
content: { application/json: { schema: { $ref: '#/components/schemas/FunnelReport' } } }
/v1/admin/analytics/retention:
post:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }]
summary: Measure return-event retention for an event cohort
requestBody:
required: true
content: { application/json: { schema: { $ref: '#/components/schemas/RetentionRequest' } } }
responses:
'200':
description: Retention report with cohort denominator and interval rates
content: { application/json: { schema: { $ref: '#/components/schemas/RetentionReport' } } }
/v1/admin/analytics/segment:
post:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }]
summary: Measure a user segment from event frequency
requestBody:
required: true
content: { application/json: { schema: { $ref: '#/components/schemas/SegmentRequest' } } }
responses:
'200':
description: Segment membership counts
content: { application/json: { schema: { $ref: '#/components/schemas/SegmentReport' } } }
/v1/admin/analytics/experiment:
post:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }]
summary: Measure deterministic weighted experiment control groups
requestBody:
required: true
content: { application/json: { schema: { $ref: '#/components/schemas/ExperimentRequest' } } }
responses:
'200':
description: Experiment assignment and conversion counts
content: { application/json: { schema: { $ref: '#/components/schemas/ExperimentReport' } } }
/v1/admin/achievements:
get:
tags: [Administration]
security: [{ adminKey: [] }]
summary: List achievements
responses: { '200': { description: Achievements } }
post:
tags: [Administration]
security: [{ adminKey: [] }]
summary: Create an achievement
requestBody:
required: true
content: { application/json: { schema: { $ref: '#/components/schemas/AchievementRequest' } } }
responses: { '201': { description: Achievement created } }
/v1/admin/levels:
get:
tags: [Administration]
security: [{ adminKey: [] }]
summary: List XP levels
parameters:
- { name: tenant_id, in: query, schema: { type: string } }
- { name: environment_id, in: query, schema: { type: string } }
responses:
'200':
description: XP levels
content: { application/json: { schema: { type: array, items: { $ref: '#/components/schemas/Level' } } } }
post:
tags: [Administration]
security: [{ adminKey: [] }]
summary: Create an XP level
requestBody:
required: true
content: { application/json: { schema: { $ref: '#/components/schemas/LevelRequest' } } }
responses:
'201':
description: XP level created
content: { application/json: { schema: { $ref: '#/components/schemas/Level' } } }
/v1/admin/rewards:
get:
tags: [Administration]
security: [{ adminKey: [] }]
summary: List active and inactive rewards
parameters:
- { name: tenant_id, in: query, schema: { type: string } }
- { name: environment_id, in: query, schema: { type: string } }
responses: { '200': { description: Rewards } }
post:
tags: [Administration]
security: [{ adminKey: [] }]
summary: Configure a digital unlock reward
requestBody:
required: true
content: { application/json: { schema: { $ref: '#/components/schemas/RewardRequest' } } }
responses: { '201': { description: Reward created } }
/v1/admin/rule-executions:
get:
tags: [Administration]
security: [{ adminKey: [] }]
summary: List rule and action execution records
parameters:
- { $ref: '#/components/parameters/Limit' }
- { $ref: '#/components/parameters/Offset' }
- { name: tenant_id, in: query, schema: { type: string } }
- { name: environment_id, in: query, schema: { type: string } }
- { name: status, in: query, schema: { type: string, enum: [pending, recorded, failed] } }
responses: { '200': { description: Execution records } }
/v1/admin/action-executions:
get:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }]
summary: Alias for rule execution records
parameters:
- { $ref: '#/components/parameters/Limit' }
- { $ref: '#/components/parameters/Offset' }
- { name: tenant_id, in: query, schema: { type: string } }
- { name: environment_id, in: query, schema: { type: string } }
- { name: status, in: query, schema: { type: string } }
responses: { '200': { description: Execution records } }
/v1/admin/redemptions:
get:
tags: [Administration]
security: [{ adminKey: [] }]
summary: List reward redemption delivery states
parameters:
- { $ref: '#/components/parameters/Limit' }
- { name: tenant_id, in: query, schema: { type: string } }
- { name: environment_id, in: query, schema: { type: string } }
- { name: status, in: query, schema: { type: string } }
responses:
'200':
description: Redemption records
content: { application/json: { schema: { $ref: '#/components/schemas/Redemptions' } } }
/v1/admin/redemptions/test:
post:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }]
summary: Test a scoped reward redemption
requestBody:
required: true
content: { application/json: { schema: { $ref: '#/components/schemas/AdminRedemptionRequest' } } }
responses: { '200': { description: Redemption state }, '202': { description: Delivery is being reconciled } }
/v1/admin/redemptions/retry:
post:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }]
summary: Retry a scoped redemption
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [tenant_id, environment_id, redemption_id]
properties:
tenant_id: { type: string }
environment_id: { type: string }
redemption_id: { type: string }
responses: { '200': { description: Redemption state }, '409': { $ref: '#/components/responses/Conflict' } }
/v1/admin/redemptions/{redemptionId}/attempts:
get:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }]
summary: List provider delivery and reconciliation attempts
parameters:
- { $ref: '#/components/parameters/RedemptionId' }
- { name: tenant_id, in: query, required: true, schema: { type: string } }
- { name: environment_id, in: query, schema: { type: string } }
responses:
'200':
description: Attempt history
content: { application/json: { schema: { type: array, items: { $ref: '#/components/schemas/RedemptionAttempt' } } } }
/v1/admin/reward-providers:
get:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }]
summary: List scope-specific reward provider configurations
parameters:
- { name: tenant_id, in: query, schema: { type: string } }
- { name: environment_id, in: query, schema: { type: string } }
responses:
'200':
description: Provider configurations without secrets
content: { application/json: { schema: { type: array, items: { $ref: '#/components/schemas/RewardProviderConfig' } } } }
post:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }]
summary: Create or update a scope-specific reward provider
requestBody:
required: true
content: { application/json: { schema: { $ref: '#/components/schemas/RewardProviderConfigRequest' } } }
responses:
'200':
description: Provider configuration without the token
content: { application/json: { schema: { $ref: '#/components/schemas/RewardProviderConfig' } } }
'400': { $ref: '#/components/responses/ValidationError' }
/v1/admin/leaderboards:
post:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }, { accessKeyBearer: [] }]
summary: Create a leaderboard
description: Limited by the max_leaderboards plan entitlement.
requestBody:
required: true
content: { application/json: { schema: { $ref: '#/components/schemas/LeaderboardRequest' } } }
responses:
'201': { description: Leaderboard created, content: { application/json: { schema: { $ref: '#/components/schemas/Leaderboard' } } } }
'400': { $ref: '#/components/responses/ValidationError' }
'409': { description: The key is taken or the plan limit is reached, content: { application/json: { schema: { $ref: '#/components/schemas/Error' } } } }
get:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }, { accessKeyBearer: [] }]
summary: List leaderboards with the round each one shows
parameters:
- { name: tenant_id, in: query, required: true, schema: { type: string } }
- { name: environment_id, in: query, required: true, schema: { type: string } }
responses:
'200': { description: Leaderboards, content: { application/json: { schema: { type: array, items: { $ref: '#/components/schemas/Leaderboard' } } } } }
/v1/admin/user-leaderboards:
get:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }, { accessKeyBearer: [] }]
summary: Read a user's place on every active leaderboard
parameters:
- { name: tenant_id, in: query, required: true, schema: { type: string } }
- { name: environment_id, in: query, required: true, schema: { type: string } }
- { name: user_id, in: query, required: true, schema: { type: string } }
responses:
'200':
description: The user's standings
content:
application/json:
schema:
type: object
properties:
user_id: { type: string }
leaderboards: { type: array, items: { $ref: '#/components/schemas/UserLeaderboardStanding' } }
/v1/admin/leaderboards/{leaderboardId}:
patch:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }, { accessKeyBearer: [] }]
summary: Rename a leaderboard or change its schedule
description: >-
The key and metric cannot change. A new schedule takes effect at the next boundary: a running
round keeps its window, and an open manual round ends where the first scheduled round begins.
Use catalog-status with resource leaderboard to turn a board off or on.
parameters: [{ $ref: '#/components/parameters/LeaderboardId' }]
requestBody:
required: true
content: { application/json: { schema: { $ref: '#/components/schemas/LeaderboardRequest' } } }
responses:
'200': { description: Leaderboard updated, content: { application/json: { schema: { $ref: '#/components/schemas/Leaderboard' } } } }
'404': { $ref: '#/components/responses/NotFound' }
'409': { description: Scheduled rounds must be cancelled before switching to a recurring schedule, content: { application/json: { schema: { $ref: '#/components/schemas/Error' } } } }
delete:
tags: [Administration]
security: [{ adminKey: [] }, { adminSession: [] }, { accessKeyBearer: [] }]
summary: Delete a leaderboard with its rounds and scores
description: Balances and XP are not touched. To stop scoring but keep history, turn the board off with catalog-status instead.
parameters:
- $ref: '#/components/parameters/LeaderboardId'
- { name: tenant_id, in: query, required: true, schema: { type: string } }
- { name: environment_id, in: query, required: true, schema: { type: string } }
responses:
'200':
description: Leaderboard deleted
content:
application/json:
schema:
type: object
properties: { deleted: { type: boolean }, id: { type: string }, key: { type: string }, rounds_deleted: { type: integer } }
'404': { $ref: '#/components/responses/NotFound' }
/v1/admin/leaderboards/{leaderboardId}/standings:
get: