## Create Credential

`client.Credentials.New(ctx, body) (*Credential, error)`

**post** `/v5/credentials`

Create a new credential for storing sensitive data like API keys, tokens, or other secrets.

### Parameters

- `body CredentialNewParams`

  - `Name param.Field[string]`

    User-friendly name for the credential

  - `Payload param.Field[string]`

    The credential payload to be encrypted

  - `Type param.Field[string]`

    Type of credential: key or json

  - `CredentialMetadata param.Field[map[string, any]]`

    Optional unencrypted credential_metadata

  - `Description param.Field[string]`

    Optional description

### Returns

- `type Credential struct{…}`

  - `ID string`

  - `CreatedAt Time`

  - `CreatedByIdentityType string`

  - `CreatedByUserID string`

  - `CredentialMetadata map[string, any]`

  - `Description string`

  - `Name string`

  - `Type string`

  - `UpdatedAt Time`

  - `Object string`

### Example

```go
package main

import (
  "context"
  "fmt"

  "github.com/scaleapi/sgp-dev-go"
  "github.com/scaleapi/sgp-dev-go/option"
)

func main() {
  client := sgpdev.NewClient(
    option.WithAPIKey("My API Key"),
    option.WithAccountID("My Account ID"),
  )
  credential, err := client.Credentials.New(context.TODO(), sgpdev.CredentialNewParams{
    Name: "x",
    Payload: "x",
    Type: "x",
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", credential.ID)
}
```

#### Response

```json
{
  "id": "id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "created_by_identity_type": "created_by_identity_type",
  "created_by_user_id": "created_by_user_id",
  "credential_metadata": {
    "foo": "bar"
  },
  "description": "description",
  "name": "name",
  "type": "type",
  "updated_at": "2019-12-27T18:11:19.117Z",
  "object": "object"
}
```
