-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopenapi_spec.yaml
461 lines (434 loc) · 13.3 KB
/
openapi_spec.yaml
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
openapi: 3.0.3
info:
title: Semrush AppCenter API
version: 0.0.1
description: |
This API allows retrieving data about user subscriptions
and operating with user email subscriptions.
servers:
- url: https://api.semrush.com
paths:
/app-center-api/v2/jwt-token/:
post:
tags: ["JWT issuer"]
summary: Request API access token
description: |
Retrieves JWT for accessing Semrush API.
[Documentation](https://www.semrush.com/apps/docs/server-to-server-api/bearer-token)
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/issuerJwtRequest"
responses:
"200":
description: "OK"
content:
application/json:
schema:
$ref: "#/components/schemas/issuerJwtResponse"
"403":
description: "Access denied"
content:
text/html:
schema:
$ref: "#/components/schemas/errorMessage"
'400':
$ref: '#/components/responses/400'
'401':
$ref: '#/components/responses/401'
/apis/v4/app-center/v2/partner/viewer-status:
post:
tags: ["Partner Service"]
summary: User status
description: |
Retrieves user status, related to the app (purchases, subscriptions)
[Documentation](https://www.semrush.com/apps/docs/server-to-server-api/viewer-status)
security:
- jwtIssuerToken: []
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/viewerStatusRequest"
responses:
"200":
description: "OK"
content:
application/json:
schema:
$ref: "#/components/schemas/viewerStatusResponse"
'400':
$ref: '#/components/responses/400'
'401':
$ref: '#/components/responses/401'
/apis/v4/hermes/v0/subscriptions:
get:
tags: ["Hermes Partner API"]
summary: Get available subscriptions
description: |
List all application's registered subscriptions
[Documentation](https://www.semrush.com/apps/docs/server-to-server-api/notifications#available-subscriptions)
security:
- jwtIssuerToken: []
responses:
"200":
description: "OK"
content:
application/json:
schema:
$ref: "#/components/schemas/appSubscriptionsResponse"
'400':
$ref: '#/components/responses/400'
'401':
$ref: '#/components/responses/401'
/apis/v4/hermes/v0/user/{user_id}/subscription/{id}:
get:
tags: ["Hermes Partner API"]
summary: Get user's subscription status
description: |
[Documentation](https://www.semrush.com/apps/docs/server-to-server-api/notifications#subscription-status)
security:
- jwtIssuerToken: [ ]
parameters:
- in: path
name: user_id
schema:
type: integer
required: true
description: User id
- in: path
name: id
schema:
type: integer
required: true
description: Subscription id
responses:
"200":
description: "OK"
content:
application/json:
schema:
$ref: "#/components/schemas/appUserSubscriptionStatusResponse"
'400':
$ref: '#/components/responses/400'
'401':
$ref: '#/components/responses/401'
/apis/v4/hermes/v0/event:
post:
tags: ["Hermes Partner API"]
summary: Send notification
description: |
[Documentation](https://www.semrush.com/apps/docs/server-to-server-api/notifications#sending-notification)
security:
- jwtIssuerToken: [ ]
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/createEventRequest"
responses:
"201":
description: "Created"
'400':
$ref: '#/components/responses/400'
'401':
$ref: '#/components/responses/401'
/apis/v4/hermes/v0/event/{id}:
get:
tags: ["Hermes Partner API"]
summary: Get event status
description: |
[Documentation](https://www.semrush.com/apps/docs/server-to-server-api/notifications#event-status)
security:
- jwtIssuerToken: [ ]
parameters:
- in: path
name: id
schema:
type: string
format: uuid
description: Global event identifier
required: true
description: Subscription id
responses:
"200":
description: "OK"
content:
application/json:
schema:
$ref: "#/components/schemas/eventResponse"
'400':
$ref: '#/components/responses/400'
'401':
$ref: '#/components/responses/401'
components:
responses:
"400":
description: "Bad request. Something wrong with the request or JWT"
content:
application/json:
schema:
$ref: "#/components/schemas/errorMessage"
"401":
description: "Unauthorized. Incorrect JWT fields or signature"
content:
application/json:
schema:
$ref: "#/components/schemas/errorMessage"
schemas:
actionNotification:
type: object
description: Action notification details
properties:
channel:
type: string
description: Sending channel
subscription_id:
type: integer
description: ID of subscription
recipient_id:
type: integer
description: ID of subscriber
eventAction:
type: object
description: Action that can be taken on event
properties:
id:
type: string
format: uuid
description: Global action identifier
ts:
type: string
format: date-time
description: Action create time in ISO format
type:
type: string
example: notification
description: Action type
finished:
type: boolean
description: Did action accomplished
notification:
$ref: "#/components/schemas/actionNotification"
eventState:
type: integer
enum: [1, 2, 3, 4, 5]
description: |
State of event processing.
* 1 - Event has been registered and awaiting processing
* 2 - Event processing was delayed
* 3 - Event was processed
* 4 - Event has nothing to do with
* 5 - Event processing was blocked by internal rules
eventResponse:
type: object
description: Create event response object
properties:
meta:
$ref: "#/components/schemas/responseMeta"
data:
type: object
description: Event status response
properties:
id:
type: string
format: uuid
description: Global event identifier
ts:
type: string
format: date-time
description: Event registration time in ISO format
state:
$ref: "#/components/schemas/eventState"
state_on:
type: string
format: date-time
description: Time when event get in current state in ISO format
decision:
type: string
description: Processing decision
actions:
type: array
description: Actions taken on event
items:
$ref: "#/components/schemas/eventAction"
eventAttachment:
type: object
description: Event additional files
properties:
name:
type: string
description: File name
mime:
type: string
example: application/pdf
description: File content mime type
content:
type: string
format: byte
example: eyJkYXRhX2tleSI6ImRhdGFfdmFsdWUxIn0=
description: File content in Base64
createEventRequest:
type: object
properties:
type:
type: string
description: type of event
id:
type: string
format: uuid
description: UUID, global event identifier, idempotency key; we suggest using V4 UUIDs
user_id:
type: integer
description: Semrush's user ID
data:
type: string
format: byte
example: eyJkYXRhX2tleSI6ImRhdGFfdmFsdWUxIn0=
attachments:
type: array
description: Additional files
items:
$ref: "#/components/schemas/eventAttachment"
appUserSubscriptionStatusResponse:
type: object
description: User subscription status response object
properties:
meta:
$ref: "#/components/schemas/responseMeta"
data:
type: object
description: An object describes subscription status related to user
properties:
active:
type: boolean
description: Does user subscribed on requested subscription
appSubscriptionsResponse:
type: object
description: Available subscriptions response object
properties:
meta:
$ref: "#/components/schemas/responseMeta"
data:
type: object
description: An object describes all app subscriptions
properties:
subscriptions:
type: array
description: app subscriptions
items:
type: object
description: available subscription
properties:
id:
type: integer
description: Subscription ID
name:
type: string
description: Subscription name
description:
type: string
description: Subscription description
viewerActiveProduct:
type: object
properties:
id:
type: string
format: uuid
description: UUID of product
value:
type: integer
description: Amount of bought product (1 for one-time products, >1 in other cases)
minimum: 0
viewerStatusResponse:
type: object
description: Viewer Status response object
properties:
meta:
$ref: "#/components/schemas/responseMeta"
data:
type: object
description: An object describes user status, related to the app
properties:
is_main_product_active:
type: boolean
description: Shows if the app's main product is active
is_app_taken_for_free:
type: boolean
description: Shows if the app is taken for free
is_main_product_trial_available:
type: boolean
description: true if a user can activate trial for app's main product
product_trials_available:
type: array
description: All app's products ids, for which user can activate trial
items:
type: string
format: uuid
description: product id
active_products:
type: array
description: List of user's in-app purchases (bought products)
minItems: 0
items:
$ref: "#/components/schemas/viewerActiveProduct"
extra_user_data:
type: object
nullable: true
description: Reserved for future use
responseMeta:
type: object
description: Response metadata
properties:
success:
type: boolean
status_code:
type: integer
example: 200
request_id:
type: string
viewerStatusRequest:
type: object
properties:
user_id:
type: integer
description: Semrush user ID
errorMessage:
type: string
maxLength: 256
description: A text message describing an error
issuerErrorMessage:
type: object
description: An object describing an error
properties:
message:
type: string
message_code:
type: string
code:
type: integer
issuerJwtRequest:
type: object
properties:
jwt:
type: string
description: |
JWT by [specification](https://www.semrush.com/apps/docs/server-to-server-api/bearer-token#generate-a-jwt),
signed by your secret key
example: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...0NiL86tQkUG25G3Y1QC2ma94sfe4cXcs8_bYcpw2OzY
issuerJwtResponse:
type: object
description: An object describing a JWT
properties:
jwt:
type: string
example: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9...0NiL86tQkUG25G3Y1QC2ma94sfe4cXcs8_bYcpw2OzY
securitySchemes:
jwtIssuerToken:
type: http
scheme: bearer
bearerFormat: JWT
description: |
Use token retrieved from Jwt Issuer
[Documentation](https://www.semrush.com/apps/docs/server-to-server-api/bearer-token)