Subscription - Create Or Update
Creates or updates the subscription of specified user to the specified product.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}?api-version=2024-05-01
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/subscriptions/{sid}?notify={notify}&api-version=2024-05-01&appType={appType}
URI Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
|
resource
|
path | True |
string minLength: 1maxLength: 90 |
The name of the resource group. The name is case insensitive. |
|
service
|
path | True |
string minLength: 1maxLength: 50 pattern: ^[a-zA-Z](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?$ |
The name of the API Management service. |
|
sid
|
path | True |
string maxLength: 256pattern: ^[^*#&+:<>?]+$ |
Subscription entity Identifier. The entity represents the association between a user and a product in API Management. |
|
subscription
|
path | True |
string (uuid) |
The ID of the target subscription. The value must be an UUID. |
|
api-version
|
query | True |
string minLength: 1 |
The API version to use for this operation. |
|
app
|
query |
Determines the type of application which send the create user request. Default is legacy publisher portal. |
||
|
notify
|
query |
boolean |
Notify change in Subscription State.
|
Request Header
| Name | Required | Type | Description |
|---|---|---|---|
| If-Match |
string |
ETag of the Entity. Not required when creating an entity, but required when updating an entity. |
Request Body
| Name | Required | Type | Description |
|---|---|---|---|
| properties.displayName | True |
string minLength: 1maxLength: 100 |
Subscription name. |
| properties.scope | True |
string |
Scope like /products/{productId} or /apis or /apis/{apiId}. |
| properties.allowTracing |
boolean |
Determines whether tracing can be enabled |
|
| properties.ownerId |
string |
User (user id path) for whom subscription is being created in form /users/{userId} |
|
| properties.primaryKey |
string minLength: 1maxLength: 256 |
Primary subscription key. If not specified during request key will be generated automatically. |
|
| properties.secondaryKey |
string minLength: 1maxLength: 256 |
Secondary subscription key. If not specified during request key will be generated automatically. |
|
| properties.state |
Initial subscription state. If no value is specified, subscription is created with Submitted state. Possible states are * active – the subscription is active, * suspended – the subscription is blocked, and the subscriber cannot call any APIs of the product, * submitted – the subscription request has been made by the developer, but has not yet been approved or rejected, * rejected – the subscription request has been denied by an administrator, * cancelled – the subscription has been cancelled by the developer or administrator, * expired – the subscription reached its expiration date and was deactivated. |
Responses
| Name | Type | Description |
|---|---|---|
| 200 OK |
The user already subscribed to the product. Headers ETag: string |
|
| 201 Created |
The user was successfully subscribed to the product. Headers ETag: string |
|
| Other Status Codes |
Error response describing why the operation failed. |
Security
azure_auth
Azure Active Directory OAuth2 Flow.
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
| Name | Description |
|---|---|
| user_impersonation | impersonate your user account |
Examples
ApiManagementCreateSubscription
Sample request
PUT https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/subscriptions/testsub?api-version=2024-05-01
{
"properties": {
"ownerId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/57127d485157a511ace86ae7",
"scope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/5600b59475ff190048060002",
"displayName": "testsub"
}
}
Sample response
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/subscriptions/testsub",
"type": "Microsoft.ApiManagement/service/subscriptions",
"name": "testsub",
"properties": {
"ownerId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/57127d485157a511ace86ae7",
"scope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/5600b59475ff190048060002",
"displayName": "testsub",
"state": "submitted",
"createdDate": "2017-06-02T23:34:03.1055076Z"
}
}
{
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/subscriptions/testsub",
"type": "Microsoft.ApiManagement/service/subscriptions",
"name": "testsub",
"properties": {
"ownerId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/57127d485157a511ace86ae7",
"scope": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/5600b59475ff190048060002",
"displayName": "testsub",
"state": "submitted",
"createdDate": "2017-06-02T23:34:03.1055076Z"
}
}
Definitions
| Name | Description |
|---|---|
|
App |
Determines the type of application which send the create user request. Default is legacy publisher portal. |
|
Error |
The resource management error additional info. |
|
Error |
The error detail. |
|
Error |
Error response |
|
Subscription |
Subscription details. |
|
Subscription |
Subscription create details. |
|
Subscription |
Subscription state. Possible states are * active – the subscription is active, * suspended – the subscription is blocked, and the subscriber cannot call any APIs of the product, * submitted – the subscription request has been made by the developer, but has not yet been approved or rejected, * rejected – the subscription request has been denied by an administrator, * cancelled – the subscription has been cancelled by the developer or administrator, * expired – the subscription reached its expiration date and was deactivated. |
AppType
Determines the type of application which send the create user request. Default is legacy publisher portal.
| Value | Description |
|---|---|
| portal |
User create request was sent by legacy developer portal. |
| developerPortal |
User create request was sent by new developer portal. |
ErrorAdditionalInfo
The resource management error additional info.
| Name | Type | Description |
|---|---|---|
| info |
object |
The additional info. |
| type |
string |
The additional info type. |
ErrorDetail
The error detail.
| Name | Type | Description |
|---|---|---|
| additionalInfo |
The error additional info. |
|
| code |
string |
The error code. |
| details |
The error details. |
|
| message |
string |
The error message. |
| target |
string |
The error target. |
ErrorResponse
Error response
| Name | Type | Description |
|---|---|---|
| error |
The error object. |
SubscriptionContract
Subscription details.
| Name | Type | Description |
|---|---|---|
| id |
string |
Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} |
| name |
string |
The name of the resource |
| properties.allowTracing |
boolean |
Determines whether tracing is enabled |
| properties.createdDate |
string (date-time) |
Subscription creation date. The date conforms to the following format: |
| properties.displayName |
string minLength: 0maxLength: 100 |
The name of the subscription, or null if the subscription has no name. |
| properties.endDate |
string (date-time) |
Date when subscription was cancelled or expired. The setting is for audit purposes only and the subscription is not automatically cancelled. The subscription lifecycle can be managed by using the |
| properties.expirationDate |
string (date-time) |
Subscription expiration date. The setting is for audit purposes only and the subscription is not automatically expired. The subscription lifecycle can be managed by using the |
| properties.notificationDate |
string (date-time) |
Upcoming subscription expiration notification date. The date conforms to the following format: |
| properties.ownerId |
string |
The user resource identifier of the subscription owner. The value is a valid relative URL in the format of /users/{userId} where {userId} is a user identifier. |
| properties.primaryKey |
string minLength: 1maxLength: 256 |
Subscription primary key. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. |
| properties.scope |
string |
Scope like /products/{productId} or /apis or /apis/{apiId}. |
| properties.secondaryKey |
string minLength: 1maxLength: 256 |
Subscription secondary key. This property will not be filled on 'GET' operations! Use '/listSecrets' POST request to get the value. |
| properties.startDate |
string (date-time) |
Subscription activation date. The setting is for audit purposes only and the subscription is not automatically activated. The subscription lifecycle can be managed by using the |
| properties.state |
Subscription state. Possible states are * active – the subscription is active, * suspended – the subscription is blocked, and the subscriber cannot call any APIs of the product, * submitted – the subscription request has been made by the developer, but has not yet been approved or rejected, * rejected – the subscription request has been denied by an administrator, * cancelled – the subscription has been cancelled by the developer or administrator, * expired – the subscription reached its expiration date and was deactivated. |
|
| properties.stateComment |
string |
Optional subscription comment added by an administrator when the state is changed to the 'rejected'. |
| type |
string |
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" |
SubscriptionCreateParameters
Subscription create details.
| Name | Type | Description |
|---|---|---|
| properties.allowTracing |
boolean |
Determines whether tracing can be enabled |
| properties.displayName |
string minLength: 1maxLength: 100 |
Subscription name. |
| properties.ownerId |
string |
User (user id path) for whom subscription is being created in form /users/{userId} |
| properties.primaryKey |
string minLength: 1maxLength: 256 |
Primary subscription key. If not specified during request key will be generated automatically. |
| properties.scope |
string |
Scope like /products/{productId} or /apis or /apis/{apiId}. |
| properties.secondaryKey |
string minLength: 1maxLength: 256 |
Secondary subscription key. If not specified during request key will be generated automatically. |
| properties.state |
Initial subscription state. If no value is specified, subscription is created with Submitted state. Possible states are * active – the subscription is active, * suspended – the subscription is blocked, and the subscriber cannot call any APIs of the product, * submitted – the subscription request has been made by the developer, but has not yet been approved or rejected, * rejected – the subscription request has been denied by an administrator, * cancelled – the subscription has been cancelled by the developer or administrator, * expired – the subscription reached its expiration date and was deactivated. |
SubscriptionState
Subscription state. Possible states are * active – the subscription is active, * suspended – the subscription is blocked, and the subscriber cannot call any APIs of the product, * submitted – the subscription request has been made by the developer, but has not yet been approved or rejected, * rejected – the subscription request has been denied by an administrator, * cancelled – the subscription has been cancelled by the developer or administrator, * expired – the subscription reached its expiration date and was deactivated.
| Value | Description |
|---|---|
| suspended | |
| active | |
| expired | |
| submitted | |
| rejected | |
| cancelled |