@lap v0.3
# Machine-readable API spec. Each @endpoint block is one API call.
@api redirection.io
@base https://api.redirection.io/
@version 2.0.0
@auth Bearer bearer | ApiKey Authorization in header
@endpoints 24
@hint download_for_search
@toc domains(4), drafts(3), instances(3), ips(1), organization(1), projects(5), redirections(1), rules(6)

@group domains
@endpoint GET /domains
@desc Retrieves the collection of the domains.
@required {projectId: str # The id of the project.}
@optional {searchAfterId: str # The id of the last domain returned in the previous page. Used for pagination.}
@returns(200) ProjectDomain collection
@errors {403: Forbidden}

@endpoint POST /domains
@desc Creates a new domain
@required {domain: str, project: str(iri-reference) # An IRI reference to the project, of the form `/projects/{project_id}`.}
@optional {backendAddress: str # The address of this backend, if there is one., backendAllowInvalidCertificate: bool=true, backendEnabled: bool=false, backendUseSsl: bool=true, sslAutomatic: bool=true, sslEnabled: bool=true}
@returns(201) {backendAddress: str?, backendAllowInvalidCertificate: bool, backendEnabled: bool, backendUseSsl: bool, dnsValid: bool, domain: str, id: str, records: [map], sslAutomatic: bool, sslEnabled: bool} # ProjectDomain resource created
@errors {400: Invalid input, 403: Forbidden, 422: An error occurred}

@endpoint DELETE /domains/{id}
@desc Permanently deletes a domain
@required {id: str # ProjectDomain identifier}
@returns(204) ProjectDomain resource deleted
@errors {403: Forbidden, 404: Not found}

@endpoint GET /domains/{id}
@desc Retrieves a ProjectDomain resource.
@required {id: str # ProjectDomain identifier}
@returns(200) {backendAddress: str?, backendAllowInvalidCertificate: bool, backendEnabled: bool, backendUseSsl: bool, dnsValid: bool, domain: str, id: str, records: [map], sslAutomatic: bool, sslEnabled: bool} # ProjectDomain resource
@errors {403: Forbidden, 404: Not found}

@endgroup

@group drafts
@endpoint GET /drafts
@desc Retrieves the collection of Draft rules
@required {projectId: str # The id of the project.}
@optional {searchAfterId: str # The id of the last draft returned in the previous page. Used for pagination., tags: [str] # The name of one or more tags. Every draft that is attached to at least one of those tags will be returned. Tags can also be passed as a comma separated list., enabled: bool # The enabled status of the rule., triggerUrl: str # The trigger source URL. This allows to filter draft rules that are triggered by a specific URL.}
@returns(200) Draft collection

@endpoint DELETE /drafts/{id}
@desc Deletes a Draft
@required {id: str # Draft identifier}
@returns(204) Draft resource deleted
@errors {403: Forbidden, 404: Not found}

@endpoint GET /drafts/{id}
@desc Retrieves a Draft resource.
@required {id: str # Draft identifier}
@returns(200) {id: str, rule: map{actions: [map], description: str?, enabled: bool, examples: [map], id: str, lastUsedAt: str(date-time)?, markers: [map], metadata: map, priority: int, tags: [str], trigger: map{date: [map], datetime: [map], excludeMethods: bool, excludeResponseStatusCodes: bool, ipAddress: any, methods: [str], requestHeaders: [map], responseStatusCodes: [int], sampling: int?, source: str, time: [map]}, usageCount: int, variables: [map]}, status: str} # Draft resource
@errors {403: Forbidden, 404: Not found}

@endgroup

@group instances
@endpoint GET /instances
@desc List project instances
@required {projectId: str # The id of the project.}
@optional {name: str # The name of the instance., searchAfterId: str # The id of the last instance returned in the previous page. Used for pagination.}
@returns(200) Instance collection
@errors {403: Forbidden}

@endpoint DELETE /instances/{id}
@desc Delete an instance
@required {id: str # Instance identifier}
@returns(204) Instance resource deleted
@errors {403: Forbidden, 404: Not found}

@endpoint GET /instances/{id}
@desc Retrieves a Instance resource.
@required {id: str # Instance identifier}
@returns(200) {agentVersion: str, agentVersionStatus: str, createdAt: str(date-time), id: str, logging: bool?, logsLastFlushedAt: str(date-time)?, misconfigured: bool, name: str, rulesCount: int, rulesLastUpdatedAt: str(date-time)?} # Instance resource
@errors {403: Forbidden, 404: Not found}

@endgroup

@group ips
@endpoint GET /ips
@desc Retrieves the collection of Ip resources.
@returns(200) Ip collection

@endgroup

@group organization
@endpoint GET /organization
@desc Retrieve the details of your organization
@returns(200) {id: str, name: str, projects: [map], slug: str} # Organization resource

@endgroup

@group projects
@endpoint GET /projects
@desc Retrieves the collection of Project resources.
@returns(200) Project collection

@endpoint POST /projects
@desc Creates a new project
@required {name: str}
@optional {metadata: map}
@returns(201) {id: str, metadata: map, name: str, plan: str, slug: str} # Project resource created
@errors {400: Invalid input, 422: An error occurred}

@endpoint DELETE /projects/{id}
@desc Permanently deletes a project
@required {id: str # Project identifier}
@returns(204) Project resource deleted
@errors {403: Forbidden, 404: Not found}

@endpoint GET /projects/{id}
@desc Retrieves a Project resource.
@required {id: str # Project identifier}
@returns(200) {id: str, metadata: map, name: str, plan: str, slug: str} # Project resource
@errors {403: Forbidden, 404: Not found}

@endpoint POST /projects/{id}/publish
@desc Publishes the collection of Draft resources
@required {id: str # The id of the project.}
@returns(204) Draft resources collection published
@errors {400: Invalid input, 403: Forbidden}

@endgroup

@group redirections
@endpoint POST /redirections
@desc Creates a new Redirection
@required {project: str(iri-reference) # An IRI reference to the project, of the form `/projects/{project_id}`., source: str # The URL to be redirected. This URL must start with `/`, `://`, `http://` or `https://`, statusCode: int(301/302/307/308) # The status code to use for this redirection., target: str # The redirection target URL. It must can be a relative URL (starting with `/`) or an absolute one (starting with `://`, `http://` or `https://`).}
@optional {description: str # This description field is used to describe the rule and share knowledge with other users, enabled: bool=true # Set to "false" to disable this rule. Even once published, this rule will not be used by your website, priority: int=0 # A rule with higher priority takes precedence over lower priorities, which means that the actions defined in the higher priority rule will override the similar actions defined in a lower priority one, tags: [str] # Tags are useful to filter rules and retrieve them easily}
@returns(201) {id: str, rule: map{actions: [map], description: str?, enabled: bool, examples: [map], id: str, lastUsedAt: str(date-time)?, markers: [map], metadata: map, priority: int, tags: [str], trigger: map{date: [map], datetime: [map], excludeMethods: bool, excludeResponseStatusCodes: bool, ipAddress: any, methods: [str], requestHeaders: [map], responseStatusCodes: [int], sampling: int?, source: str, time: [map]}, usageCount: int, variables: [map]}, status: str} # Draft rule resource created (with the status `add`)
@errors {400: Invalid input, 403: Forbidden, 422: An error occurred}

@endgroup

@group rules
@endpoint GET /rules
@desc Retrieves the collection of currently published Rule resources.
@required {projectId: str # The id of the project.}
@optional {searchAfterId: str # The id of the last rule returned in the previous page. Used for pagination., tags: [str] # The name of one or more tags. Every Rule that is attached to at least one of those tags will be returned. Tags can also be passed as a comma separated list., enabled: bool # The enabled status of the rule., triggerUrl: str # The trigger source URL. This allows to filter rules that are triggered by a specific URL.}
@returns(200) Rule collection
@errors {403: Forbidden}

@endpoint POST /rules
@desc Creates a new draft Rule
@required {project: str(iri-reference) # An IRI reference to the project, of the form `/projects/{project_id}`., trigger: map{date: [map], datetime: [map], excludeMethods: bool, excludeResponseStatusCodes: bool, ipAddress: any, methods: [str], requestHeaders: [map], responseStatusCodes: [int], sampling: int, source!: str, time: [map]}}
@optional {actions: [map{}], description: str # This description field is used to describe the rule and share knowledge with other users, enabled: bool=true # Set to `false` to disable this rule, examples: [map{datetime: str(date-time), headers: [map], ipAddress: str, method: str, mustMatch!: bool, responseStatusCode: int, url!: str}], markers: [map{}], metadata: map, priority: int=0 # A rule with higher priority takes precedence over lower priorities, which means that the actions defined in the higher priority rule will override the similar actions defined in a lower priority one, tags: [str] # Tags are useful to filter rules and retrieve them easily, variables: [map{}]}
@returns(201) {id: str, rule: map{actions: [map], description: str?, enabled: bool, examples: [map], id: str, lastUsedAt: str(date-time)?, markers: [map], metadata: map, priority: int, tags: [str], trigger: map{date: [map], datetime: [map], excludeMethods: bool, excludeResponseStatusCodes: bool, ipAddress: any, methods: [str], requestHeaders: [map], responseStatusCodes: [int], sampling: int?, source: str, time: [map]}, usageCount: int, variables: [map]}, status: str} # Draft rule resource created (with the status `add`)
@errors {400: Invalid input, 403: Forbidden, 422: An error occurred}

@endpoint DELETE /rules/{id}
@desc Deletes a Rule
@required {id: str # Rule identifier}
@returns(200) {id: str, rule: map{actions: [map], description: str?, enabled: bool, examples: [map], id: str, lastUsedAt: str(date-time)?, markers: [map], metadata: map, priority: int, tags: [str], trigger: map{date: [map], datetime: [map], excludeMethods: bool, excludeResponseStatusCodes: bool, ipAddress: any, methods: [str], requestHeaders: [map], responseStatusCodes: [int], sampling: int?, source: str, time: [map]}, usageCount: int, variables: [map]}, status: str} # Draft rule resource updated (with the status `delete`)
@errors {403: Forbidden, 404: Not found}

@endpoint GET /rules/{id}
@desc Retrieves a Rule resource
@required {id: str # Rule identifier}
@returns(200) {actions: [map], description: str?, enabled: bool, examples: [map], id: str, lastUsedAt: str(date-time)?, markers: [map], metadata: map, priority: int, tags: [str], trigger: map{date: [map], datetime: [map], excludeMethods: bool, excludeResponseStatusCodes: bool, ipAddress: any, methods: [str], requestHeaders: [map], responseStatusCodes: [int], sampling: int?, source: str, time: [map]}, usageCount: int, variables: [map]} # Rule resource
@errors {403: Forbidden, 404: Not found}

@endpoint PUT /rules/{id}
@desc Updates an existing Rule
@required {id: str # Rule identifier, project: str(iri-reference) # An IRI reference to the project, of the form `/projects/{project_id}`., trigger: map{date: [map], datetime: [map], excludeMethods: bool, excludeResponseStatusCodes: bool, ipAddress: any, methods: [str], requestHeaders: [map], responseStatusCodes: [int], sampling: int, source!: str, time: [map]}}
@optional {actions: [map{}], description: str # This description field is used to describe the rule and share knowledge with other users, enabled: bool=true # Set to `false` to disable this rule, examples: [map{datetime: str(date-time), headers: [map], ipAddress: str, method: str, mustMatch!: bool, responseStatusCode: int, url!: str}], markers: [map{}], metadata: map, priority: int=0 # A rule with higher priority takes precedence over lower priorities, which means that the actions defined in the higher priority rule will override the similar actions defined in a lower priority one, tags: [str] # Tags are useful to filter rules and retrieve them easily, variables: [map{}]}
@returns(200) {id: str, rule: map{actions: [map], description: str?, enabled: bool, examples: [map], id: str, lastUsedAt: str(date-time)?, markers: [map], metadata: map, priority: int, tags: [str], trigger: map{date: [map], datetime: [map], excludeMethods: bool, excludeResponseStatusCodes: bool, ipAddress: any, methods: [str], requestHeaders: [map], responseStatusCodes: [int], sampling: int?, source: str, time: [map]}, usageCount: int, variables: [map]}, status: str} # Draft rule resource updated (with the status `update`)
@errors {400: Invalid input, 403: Forbidden, 404: Not found, 422: An error occurred}

@endpoint GET /rules/{id}/statistics
@desc Retrieves the usage statistics of a rule.
@required {id: str # The id of the rule., projectId: str}
@optional {start: str # The start date of the statistic usage in RFC 3339 format (without milliseconds). If not provided, the statistics from the rule creation date will be used., end: str # The end date of the statistic usage in RFC 3339 format (without milliseconds).}
@returns(200) RuleStatistic collection
@errors {403: Forbidden}

@endgroup

@end
