General Information
Policy Type
Description
API Authentication policy adds authentication credentials to outgoing requests to target APIs. It supports BASIC, BASE64, DIGEST, and API authentication types, and can send credentials via headers, parameters, body message, or body injection. This policy enables Apinizer to authenticate with backend APIs on behalf of clients.Endpoints
List Policies
Add Policy
Update Policy
Delete Policy
List Policies
Endpoint
Request
Headers
| Header | Value |
|---|---|
| Authorization | Bearer {token} |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| projectName | string | Yes | Project name |
| apiProxyName | string | Yes | API Proxy name |
Response
Success Response (200 OK)
apiAuthCondExpressionList are cleared for security.
cURL Example
Add Policy
Endpoint
Request
Headers
| Header | Value |
|---|---|
| Authorization | Bearer {token} |
| Content-Type | application/json |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| projectName | string | Yes | Project name |
| apiProxyName | string | Yes | API Proxy name |
| policyName | string | Yes | Policy name |
Request Body
Full JSON Body Example - BASIC Authentication with HEADER
Full JSON Body Example - BASE64 Authentication with PARAM
Full JSON Body Example - DIGEST Authentication with HEADER
Full JSON Body Example - BODY_MESSAGE Send Type
Full JSON Body Example - BODY_INJECTION Send Type
Full JSON Body Example - Using authApiName
authApiName is currently used directly as API ID. Name to ID conversion will be implemented in a future release.
Request Body Fields
operationMetadata
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| targetScope | string | Yes | - | Policy scope: ALL or ENDPOINT |
| targetEndpoint | string | No* | - | Endpoint path (required if targetScope=ENDPOINT) |
| targetEndpointHTTPMethod | string | No* | - | HTTP method (required if targetScope=ENDPOINT) |
| targetPipeline | string | Yes | - | Pipeline: REQUEST, RESPONSE, or ERROR |
| deploy | boolean | No | true | Whether to deploy after adding policy |
| deployTargetEnvironmentNameList | array | No | [] | List of environment names to deploy to |
| order | integer | No | null | Policy execution order (starts from 1) |
ALL- Policy applies to all endpointsENDPOINT- Policy applies only to specified endpoint
REQUEST- Executes in request pipeline (adds authentication to request)RESPONSE- Executes in response pipelineERROR- Executes in error pipeline
GET,POST,PUT,DELETE,PATCH,OPTIONS,HEAD
policy
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| type | string | Yes | - | Policy type: policy-api-authentication |
| description | string | No | - | Policy description |
| active | boolean | No | true | Whether policy is active |
| authType | string | No* | - | Authentication type (required if using conditional expressions) |
| sendType | string | No* | - | Send type (required if using conditional expressions) |
| messageContentType | string | No | XML | Message content type: XML, JSON, or ALL_BODY |
| usernameFieldName | string | No* | - | Username field name (required for BASIC/DIGEST with HEADER/PARAM, BODY_INJECTION) |
| passwordFieldName | string | No* | - | Password field name (required for BASIC/BASE64/DIGEST with HEADER/PARAM, BODY_INJECTION) |
| createdFieldName | string | No* | - | Created timestamp field name (required for DIGEST with HEADER/PARAM) |
| nonceFieldName | string | No* | - | Nonce field name (required for DIGEST with HEADER/PARAM) |
| bodyMessage | string | No* | - | Body message template (required for BODY_MESSAGE send type) |
| bodyMessageInjectionPath | string | No* | - | Body message injection path (required for BODY_MESSAGE send type) |
| usernameInjectionPath | string | No* | - | Username injection path (required for BODY_INJECTION send type) |
| passwordInjectionPath | string | No* | - | Password injection path (required for BODY_INJECTION send type) |
| createdInjectionPath | string | No | - | Created timestamp injection path (for DIGEST with BODY_INJECTION) |
| nonceInjectionPath | string | No | - | Nonce injection path (for DIGEST with BODY_INJECTION) |
| authApiName | string | No* | - | Authentication API name (alternative to conditional expressions) |
| apiAuthCondExpressionList | array | No* | [] | List of conditional authentication expressions (required if authApiName not provided) |
EnumPolicyApiAuthenticationAuthType
BASIC- Plain text username/password authenticationBASE64- Base64 encoded authenticationDIGEST- HTTP Digest authenticationAPI- API-based authentication
EnumPolicyApiAuthenticationSendType
HEADER- Send credentials via HTTP headersPARAM- Send credentials via query/path parametersBODY_MESSAGE- Send credentials via body message templateBODY_INJECTION- Inject credentials into existing body
EnumMessageContentType
XML- XML message contentJSON- JSON message contentALL_BODY- All body content types
Note
- Either
authApiNameorapiAuthCondExpressionListmust be provided. - If using
apiAuthCondExpressionList,authTypeandsendTypeare required. - Field name requirements vary by
authTypeandsendTypecombination. - Note:
authApiNameis currently used directly as API ID. Name to ID conversion will be implemented in a future release.
apiAuthCondExpressionList
Each conditional expression is an object with the following fields:| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| id | integer | No | - | Expression ID (auto-generated) |
| username | string | Yes | - | Username for authentication |
| password | string | Yes | - | Password for authentication (encrypted) |
| policyCondition | object | No | null | Policy condition for conditional authentication |
Note
usernameandpasswordare required.passwordis encrypted when stored.policyConditionallows conditional authentication based on request context.
Response
Success Response (200 OK)
cURL Example
Update Policy
Endpoint
Request
Headers
| Header | Value |
|---|---|
| Authorization | Bearer {token} |
| Content-Type | application/json |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| projectName | string | Yes | Project name |
| apiProxyName | string | Yes | API Proxy name |
| policyName | string | Yes | Policy name |
Request Body
Note: Request body structure is the same as Add Policy. All fields should be provided for update.Response
Success Response (200 OK)
Delete Policy
Endpoint
Request
Headers
| Header | Value |
|---|---|
| Authorization | Bearer |
| Content-Type | application/json |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| projectName | string | Yes | Project name |
| apiProxyName | string | Yes | API Proxy name |
| policyName | string | Yes | Policy name |
Request Body
Full JSON Body Example
Response
Success Response (200 OK)
Notes and Warnings
-
Authentication Type:
BASIC- Plain text username/passwordBASE64- Base64 encoded credentialsDIGEST- HTTP Digest authentication (requires created/nonce fields)API- API-based authentication
-
Send Type:
HEADER- Via HTTP headersPARAM- Via query/path parametersBODY_MESSAGE- Via body message templateBODY_INJECTION- Inject into existing body
-
Configuration: Either
authApiNameorapiAuthCondExpressionListmust be provided -
API Name:
authApiNameis currently used directly as API ID. Name to ID conversion will be implemented in a future release. -
Field Names: Required field names vary by
authTypeandsendTypecombination -
DIGEST Authentication: Requires
createdFieldNameandnonceFieldNamefor HEADER/PARAM -
BODY_MESSAGE: Requires
bodyMessagetemplate andbodyMessageInjectionPath -
BODY_INJECTION: Requires
usernameInjectionPathandpasswordInjectionPath - Conditional Expressions: Multiple expressions allow different credentials based on conditions
- Password Security: Passwords are encrypted when stored
-
Pipeline:
REQUESTpipeline adds authentication to request before forwarding to target API- Authentication is added based on configured send type
- Error Handling: Invalid authentication configuration may cause request forwarding to fail
-
Deployment: Policy changes require deployment to take effect. Set
deploy: trueor deploy manually.
Related Documentation
- List Policies - List all policies
- Add Policy - General policy addition guide
- Update Policy - General policy update guide
- Delete Policy - General policy deletion guide
- Basic Authentication Policy - Authenticate incoming requests with Basic Auth
- Digest Authentication Policy - Authenticate incoming requests with Digest Auth

