> ## Documentation Index
> Fetch the complete documentation index at: https://docs.slm.m1amdocs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Account.grantCredit

The `grantCredit` method adds credit to an `Account` object. With credit available to an `Account`, you can conduct a one-time transaction for the `Account`. If the `Account` is associated with an `AutoBill`, and if the `AutoBill` has no associated credit, Subscribe can draw credit down from the `Account` to sustain the `AutoBill`.

Specify credit you wish to grant to the `Account` as a `Credit` object. Time-based credit cannot be granted to an `Account`.

See the [Credit Subobject](Credit_Subobject), and the [TimeInterval Subobject](TimeInterval_Subobject), for more information.

See Credit Grants and Gift Cards in the Subscribe Programming Guide for more information on working with credit.

## Input

*srd*: sparse response description, a SOAP string (which must be a JSON object), in which you specify the elements you want returned.This parameter enables the calling system to constrain a `method` call to return only components you specify. This gives you greater control over returned content, and improves response time within the Vindicia platform by reducing the processing needed for the call.

Some fields are required, either practically or in the WSDL, and will be returned regardless of the *srd*. A null *srd* returns the complete response.

*account*: the `Account` object to which you wish to grant credit. Use the `merchantAccountId` or `VID` to identify the object.

*credit*: a `Credit` object specifying the amount and type of credit you wish to grant to the `Account`.

*note*: an optional memo regarding the credit grant.

## Output

*return*: an object `Account` type `Return` that indicates the success or failure of the call.

*account*: the `Account` object to which you granted credit. This object contains the updated array of `Credit` objects.

## Returns

In addition to those listed in [The Return Object](The_Return_Object), this call returns:

| Return Code | Return String |
| - | - |
| `400` | One of the following: - `Account not found.` - `Failed to translate credit *error-description*.` - `Failed to grant credit *error-description*.` - `Failed to save Account after granting credit.` - `Failed to reload Account after granting credit *error-description*.` - `Time interval credit cannot have amount 0.` |

## Example

```

// to grant credit to an account

$acct = new Account();

// account id for an existing customer

$acct->setMerchantAccountId('jdoe101');

$tok = new Token();

// specify id of an existing token type.
// assumption here is that you have already created
// a Token object with this id

$tok->setMerchantTokenId('ANYTIME_PHONE_MINUTES_2010');

$tokAmt = new TokenAmount();
$tokAmt->setToken($tok);
$tokAmt->setAmount(100);

$cr = new Credit();
$cr->setTokenAmounts(array($tokAmt));

// Now make the SOAP API call to grant credit to the acct
$response = $acct->grantCredit($cr);

if ($response['returnCode'] == 200) {

   // Credit successfully granted to the account

   $updatedAcct = $response['data']->account;
   $availableCredits = $updatedAcct->getCredit();   
   $availableTokens = $availableCredits->getTokenAmounts();

   print "Available token credits: \n";
   foreach($availableTokens as $tkAmt) {
   print "Token type: " . $tkAmt->getMerchantTokenId() . " ";
   print "Amount: " . $tkAmt->getAmount() . "\n";
   }
}
else {

// Error while granting credit to the account
print $response['returnString'] . "\n";
}
```

**Parent topic:**[Account Methods](../topics/Account_Methods)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.