class Stytch::M2M::Clients

def create(

The type of this field is +Integer+.
The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
status_code::
The type of this field is +M2MClientWithClientSecret+ (+object+).
The M2M Client created by this API call.
m2m_client::
The type of this field is +String+.
Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
request_id::
An object with the following fields:
== Returns:

The type of this field is nilable +object+.
The `trusted_metadata` field contains an arbitrary JSON object of application-specific data. See the [Metadata](https://stytch.com/docs/api/metadata) reference for complete field behavior details.
trusted_metadata::
The type of this field is nilable +String+.
A human-readable description for the client.
client_description::
The type of this field is nilable +String+.
A human-readable name for the client.
client_name::
The type of this field is nilable +String+.
If provided, the stored secret of the client to create. If not provided, Stytch will generate this value for you. If provided, the `client_secret` must be at least 8 characters long and pass entropy requirements.
client_secret::
The type of this field is nilable +String+.
If provided, the ID of the client to create. If not provided, Stytch will generate this value for you. The `client_id` must be unique within your project.
client_id::
The type of this field is list of +String+.
An array of scopes assigned to the client.
scopes::
== Parameters:

**Important:** This is the only time you will be able to view the generated `client_secret` in the API response. Stytch stores a hash of the `client_secret` and cannot recover the value if lost. Be sure to persist the `client_secret` in a secure location. If the `client_secret` is lost, you will need to trigger a secret rotation flow to receive another one.

Creates a new M2M Client. On initial client creation, you may pass in a custom `client_id` or `client_secret` to import an existing M2M client. If you do not pass in a custom `client_id` or `client_secret`, one will be generated automatically. The `client_id` must be unique among all clients in your project.
def create(
  scopes:,
  client_id: nil,
  client_secret: nil,
  client_name: nil,
  client_description: nil,
  trusted_metadata: nil
)
  headers = {}
  request = {
    scopes: scopes
  }
  request[:client_id] = client_id unless client_id.nil?
  request[:client_secret] = client_secret unless client_secret.nil?
  request[:client_name] = client_name unless client_name.nil?
  request[:client_description] = client_description unless client_description.nil?
  request[:trusted_metadata] = trusted_metadata unless trusted_metadata.nil?
  post_request('/v1/m2m/clients', request, headers)
end

def delete(

The type of this field is +Integer+.
The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
status_code::
The type of this field is +String+.
The ID of the client.
client_id::
The type of this field is +String+.
Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
request_id::
An object with the following fields:
== Returns:

The type of this field is +String+.
The ID of the client.
client_id::
== Parameters:

To protect more-sensitive routes, pass a lower `max_token_age` value when[authenticating the token](https://stytch.com/docs/b2b/api/authenticate-m2m-token)[authenticating the token](https://stytch.com/docs/api/authenticate-m2m-token).
**Important:** Deleting a M2M Client will not invalidate any existing JWTs issued to the client, only prevent it from receiving new ones.

Deletes the M2M Client.
def delete(
  client_id:
)
  headers = {}
  delete_request("/v1/m2m/clients/#{client_id}", headers)
end

def get(

The type of this field is +Integer+.
The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
status_code::
The type of this field is +M2MClient+ (+object+).
The M2M Client affected by this operation.
m2m_client::
The type of this field is +String+.
Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
request_id::
An object with the following fields:
== Returns:

The type of this field is +String+.
The ID of the client.
client_id::
== Parameters:

Gets information about an existing M2M Client.
def get(
  client_id:
)
  headers = {}
  query_params = {}
  request = request_with_query_params("/v1/m2m/clients/#{client_id}", query_params)
  get_request(request, headers)
end

def initialize(connection)

def initialize(connection)
  @connection = connection
  @secrets = Stytch::M2M::Clients::Secrets.new(@connection)
end

def search(

The type of this field is +Integer+.
The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
status_code::
The type of this field is +ResultsMetadata+ (+object+).
The search `results_metadata` object contains metadata relevant to your specific query like total and `next_cursor`.
results_metadata::
The type of this field is list of +M2MClient+ (+object+).
An array of M2M Clients that match your search query.
m2m_clients::
The type of this field is +String+.
Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
request_id::
An object with the following fields:
== Returns:

The type of this field is nilable +M2MSearchQuery+ (+object+).
The optional query object contains the operator, i.e. `AND` or `OR`, and the operands that will filter your results. Only an operator is required. If you include no operands, no filtering will be applied. If you include no query object, it will return all results with no filtering applied.
query::
The type of this field is nilable +Integer+.
The number of search results to return per page. The default limit is 100. A maximum of 1000 results can be returned by a single search request. If the total size of your result set is greater than one page size, you must paginate the response. See the `cursor` field.
limit::
The type of this field is nilable +String+.
The `cursor` field allows you to paginate through your results. Each result array is limited to 1000 results. If your query returns more than 1000 results, you will need to paginate the responses using the `cursor`. If you receive a response that includes a non-null `next_cursor` in the `results_metadata` object, repeat the search call with the `next_cursor` value set to the `cursor` field to retrieve the next page of results. Continue to make search calls until the `next_cursor` in the response is null.
cursor::
== Parameters:

- `scopes`: Search for clients assigned a specific scope
- `client_name`: Search for clients by exact match on client name
- `client_id`: Pass in a list of client IDs to get many clients in a single request
The following search filters are supported today:

Search for M2M Clients within your Stytch Project. Submit an empty `query` in the request to return all M2M Clients.
def search(
  cursor: nil,
  limit: nil,
  query: nil
)
  headers = {}
  request = {}
  request[:cursor] = cursor unless cursor.nil?
  request[:limit] = limit unless limit.nil?
  request[:query] = query unless query.nil?
  post_request('/v1/m2m/clients/search', request, headers)
end

def update(

The type of this field is +Integer+.
The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
status_code::
The type of this field is +M2MClient+ (+object+).
The M2M Client affected by this operation.
m2m_client::
The type of this field is +String+.
Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
request_id::
An object with the following fields:
== Returns:

The type of this field is nilable +object+.
The `trusted_metadata` field contains an arbitrary JSON object of application-specific data. See the [Metadata](https://stytch.com/docs/api/metadata) reference for complete field behavior details.
trusted_metadata::
The type of this field is nilable list of +String+.
An array of scopes assigned to the client.
scopes::
The type of this field is nilable +UpdateRequestStatus+ (string enum).
The status of the client - either `active` or `inactive`.
status::
The type of this field is nilable +String+.
A human-readable description for the client.
client_description::
The type of this field is nilable +String+.
A human-readable name for the client.
client_name::
The type of this field is +String+.
The ID of the client.
client_id::
== Parameters:

To protect more-sensitive routes, pass a lower `max_token_age` value when[authenticating the token](https://stytch.com/docs/b2b/api/authenticate-m2m-token)[authenticating the token](https://stytch.com/docs/api/authenticate-m2m-token).
**Important:** Deactivating a M2M Client will not invalidate any existing JWTs issued to the client, only prevent it from receiving new ones.

Updates an existing M2M Client. You can use this endpoint to activate or deactivate a M2M Client by changing its `status`. A deactivated M2M Client will not be allowed to perform future token exchange flows until it is reactivated.
def update(
  client_id:,
  client_name: nil,
  client_description: nil,
  status: nil,
  scopes: nil,
  trusted_metadata: nil
)
  headers = {}
  request = {}
  request[:client_name] = client_name unless client_name.nil?
  request[:client_description] = client_description unless client_description.nil?
  request[:status] = status unless status.nil?
  request[:scopes] = scopes unless scopes.nil?
  request[:trusted_metadata] = trusted_metadata unless trusted_metadata.nil?
  put_request("/v1/m2m/clients/#{client_id}", request, headers)
end